jQuery Fadeout on Click or after delay
<p>I am displaying a message box on a website. I would like to be able to have it either fadeout on click or after X seconds. The problem is that the <code>delay()</code> function takes the place over the <code>click()</code> function making it so even if you click close you still have to wait the time. </p>

<p>Here is the jQuery</p>

<pre><code>$(document).ready(function() {    
$(".close-green").click(function () {
        $("#message-green").fadeOut("slow");
    });

    //fade out in 5 seconds if not closed
    $("#message-green").delay(5000).fadeOut("slow");

})
</code></pre>

<p>I also set up a simple jsfiddle. To see the problem comment out the delay line <a href="http://jsfiddle.net/BandonRandon/VRYBk/1/" rel="nofollow">http://jsfiddle.net/BandonRandon/VRYBk/1/</a></p>
