There is a code http://jsfiddle.net/sHmfA/ in theory, when the cursor goes past the div, the element is hidden, but there are cases when this happens not working correctly, the element is not hidden, what's the trouble?
- onehover is not a mousein - zb '
|
3 answers
somehow so if you stay in the same markup.
$(document).ready(function () { var $likes = $('#likes'), $headerlikes = $('.headerlikes'), time; $likes.hover(function () { clearTimeout(time); $headerlikes.finish().fadeIn(500); $likes.css('color', 'rgb(232, 57, 114)'); }, function () { time = setTimeout(hidethem, 100); //это чтобы дырку пропустить между элементами. }); $headerlikes.hover(function () { clearTimeout(time); $headerlikes.finish().fadeIn(500); $likes.css('color', 'rgb(232, 57, 114)'); }, hidethem); function hidethem() { $headerlikes.finish().fadeOut(500); $likes.css('color', 'rgb(153, 153, 153)'); } }); |
Are you asking about the stop method? http://api.jquery.com/stop/
- no, there is another problem, hover over the link, and then go beyond the frame and without getting into the appeared block return to the document. something like this. - zb '
- I already understand the code, your comments and answers, what it is about, what a glitch should be observed (usually this happens when switching to another window by cmd + tab), but for some reason I don’t see this problem. But meltoshenie is in full. - Elena Levina
- Well, generally speaking, you will not change much here (I blink a little too), I tried to do stop () and there was another glitch, I think the best way would be css transitions and class switching. - zb '
|
I understand that when you hover on #likes , you force .headerlikes appear, and when you trigger the mouseleave you want .headerlikes disappear, did I understand correctly? However, if you pass a block, this code does not work, it does not work only for the reason that the mouseleave trigger requires that the mouseleave trigger be mouseleave before it. Agree, it is illogical to "leave" from where you have not been. Read more about mouseleave and look at the example at the very bottom of the page; it shows just that.
|