jquery - Javascript hide DIV, Button clicked -


hi there stackers,

i'm problem. it's javascript (again). i've been creating "alerts" on webpage. contain button, , want close them when click on button. however, doesn't seem work. i've logged clicks in console, , click logged. click happen.

the alerts hide after few seconds. when change style "devtools" of chrome make visible again, , click button then, div dissapear.

why click not hide div?

javascript

var messageid = 0;      var alerty = function(type, title, content) {         messageid++;     var html = ' <div class="alert" id="a-' + messageid + '"><div class="topview ' + type + '"></div><div class="title">' + title +'</div> <div class="text">' + content +'</div> <input type="button" id="close-'+ messageid + '" class="inputbutton-empty ' + type + '2 button close" value="meldung schlie&szlig;en"></div>'     $(html).hide().appendto("#alertcontainer").fadein("fast");     $(".alert").delay(8000).fadeout();     $("#close-" + messageid ).click(function() {         console.log("xtm: pushed alerty alert closed on request.");         $("#a-" + messageid ).hide("fade", "fast");     }); } 

thanks in advance, pascal

it delay() preventing hide() call. try clearing queue first in close function:

$("#close-" + messageid ).click(function() {         console.log("xtm: pushed alerty alert closed on request.");         $("#a-" + messageid ).stop().hide("fade", "fast");     }); 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo