Hi there Stackers,
I'm back with another problem. It's Javascript (again). I've been creating "alerts" for on my webpage. They contain a button, and I want to close them when I click on a button. However, this doesn't seem to work. I've logged the clicks in the console, and the click is logged. The click does happen.
The Alerts hide after a few seconds. When I change the style with the "Devtools" of Chrome to make it visible again, and click the button then, the DIV does dissapear.
Why does the click not hide my 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ß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