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);          }); } 

jsfiddle demo

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);          }); } 

jsfiddle demo


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -