javascript - binding setTimeOut to some function with specific element -
javascript - binding setTimeOut to some function with specific element - i trying notification pop up, each pop dynamically generated after ajax fetched data. pop each have time limit of 10seconds before fade out. see on facebook's notifications on left bottom corner. each pop hidden according time added , timelimit. here's illustration code: function hidepop(obj){ $(obj).hide(); } function newpopup(data){ $('#notifications').prepend('<li class="new" style="display:none;">'+data+'</li>'); $('.new').fadein(200, function(){ var $this = $(this); $(this).removeclass('new'); settimeout(function(){ hidepop($this) }, 10000); }); } as can see above, ajax phone call call newpopup data. 1 time fades in settimeout function run. works, however, after few more li appended, new lis maintain hiding 1 time showed. note: remove class new 1 time done sin