delay() and click() issue
This is probably a simple issue that I'm simply executing improperly, but here goes -- I'm trying to display an alert message (a div with text) that fades in, and after 6 seconds fades out automatically. That's easy, but I also want to allow the user to close the div by clicking on it if they so desire. The problem is, the delay() function overrides the click, or so it seems -- clicking does nothing unless I remove the delay(). Here's the code I'm using:
- $("#alert").fadeIn(600);
$("#alert").click(function() {
$("#alert").fadeOut(400);
});
$("#alert").delay(6000);
$("#alert").fadeOut(400);
I've tried reordering and combining these into a single statement but it yields the same result. Any ideas?