click - jQuery fadeOut() and clicking issue -
this returner, part of php-driven cms.
we want returner (if has class admin) add div hide, little x button. returner should automatically fadeout() after 4 seconds, or fadeout() if user clicks on hide button.
each of //here codes work on own, run delayed fadeout() , not clicked one!
any great. thanks, nick.
$(".success, .info, .warning, .error").each(function(){ if(!$(this).hasclass("admin")){ $(this).append('<div class="hide"></div>'); $(this).delay(4000).fadeout(); // here } }); $(".hide").click(function(){ $(this).parent().fadeout(); // here });
since .hide
appended dynamically need use .live() (or delegate) click handler function correctly.
since using delay()
try call .stop() on parent clear delay run fade out animation.
$(".hide").live('click', function(){ $(this).parent().stop().fadeout(); // here });
example of on jsfiddle.
Comments
Post a Comment