javascript - jQuery hide notification after x ms -
i found script warning message here: http://www.red-team-design.com/cool-notification-messages-with-css3-jquery
in script set hide warning message after click function
$('.message').click(function(){ $(this).animate({top: -$(this).outerheight()}, 500); }); so added timeout function in hopes of closing after x ms, 'timer' speak starts running page loaded.
settimeout(function(){hideallmessages()},5000); i want timeout function work every time form submitted , drop message becomes visible (i using hidden iframe submit form , stock, repeated submits done on same page).
i set demo here jsfiddle
you want add in showmessage function this:
function showmessage(type) { $('.'+ type +'-trigger').click(function(){ hideallmessages(); $('.'+type).animate({top:"0"}, 500); settimeout(hideallmessages,3000); }); } edit: suggested james montagne in comments, can use cleartimeout() prevent stocking timeouts if user clicks around quickly.
something (quick example, might not production-ready):
var timeout = null; function showmessage(type) { $('.'+ type +'-trigger').click(function(){ hideallmessages(); $('.'+type).animate({top:"0"}, 500); if (timeout) cleartimeout(timeout); timeout = settimeout(hideallmessages,3000); }); }
Comments
Post a Comment