I have bizarre problem. I want to .slideUp() some div after click anywhere, but only if mouse is not hovering specific elements...
$("body").mousedown(function() {
if ($(".title").is(":hover") || $(".helper").is(":hover")) return;
$(".helpers").slideUp();
});
$(".title").mouseover(function() {
$(".helpers").slideDown();
});
This code was working for me well (hover "dev_helpers" at http://siwego.net -top page), until I had to add second ".helper" element into source. After that, clicking the body, javascript dumps following error:
Error: Syntax error, unrecognized expression: unsupported pseudo: hover
I was trying to modify the code for looping elements:
$("body").mousedown(function() {
if ($(".title").is(":hover")) return;
$('.helper').each(function(i, obj) {
if ($(this).is(":hover")) return;
});
$(".helpers").slideUp();
});
$(".title").mouseover(function() {
$(".helpers").slideDown();
});
Error is not showing up anymore, but :hover check 'for each' is not working (its not preventing slideUp()).
I had to do this:
$("body").mousedown(function() {
if ($(".title").is(":hover") || $(".helper1").is(":hover") || $(".helper2").is(":hover")) return;
$(".helpers").slideUp();
});
$(".title").mouseover(function() {
$(".helpers").slideDown();
});
But its not solution for me, since I have to add new element check for each ".helperX" instance.....
Maybe someone will have any clue...
title
,helper
orhelpers
appearing in the site you have linked. Also, please avoid linking to external sites, but reproduce your issue minimally using a code snippet or do it on JSfiddle..each()
loop doesn't do anything. It tests whether the element is being hovered, but doesn't do anything depending on the result of it. The function just returns and it then goes to the next element in the loop.