I have a list of several \'triggers\' (
), each trigger shows a specific DIV, and each DIV has \'close\' button.
Now, I want to improve the us
@locrizak's answer is right (+1). This is because .delay()
defaults to the effects queue, but .hide()
with no parameters hides the selected elements without any effect, so the effects queue isn't involved at all.
If you want to hide without any animation, just use setTimeout:
$('.trigger').mouseleave(function() {
setTimeout(function () {
$('.copy .wrapper').hide();
}, 3000);
});
http://jsfiddle.net/mattball/93F3k/
//Show-Hide divs
var current;
$('.trigger').live('mouseenter', function() {
var id = current = $(this).data('code');
$('#' + id).show().siblings().fadeOut();
}).live('mouseleave', function() {
var id = $(this).data('code');
current = null;
setTimeout(function ()
{
if (current !== id) $('#' + id).hide(1);
}, 3000);
});
//Close button
$('.copy .wrapper span').live('click', function() {
$(this).closest('.wrapper').stop(true, true).fadeOut();
});
Demo: http://jsfiddle.net/mattball/b2ew5/