Jquery - check for clicks outside of a Select box
<p>I recreated a Select box and its dropdown function using this:</p>

<pre><code>$(".selectBox").click(function(e) {
    if (!$("#dropDown").css("display") || $("#dropDown").css("display") == "none")
        $("#dropDown").slideDown();
    else
        $("#dropDown").slideUp();
    e.preventDefault();
});
</code></pre>

<p>The only problem is that if you click away from the box, the dropdown stays. I'd like it to mimic a regular dropdown and close when you click away, so I thought I could do a 'body' click: </p>

<pre><code>$('body').click(function(){
    if ($("#dropdown").css("display") || $("#dropdown").css("display") != "none")
        $("#dropdown").slideUp();
});
</code></pre>

<p>But now, when you click the Select box, the dropdown slides down and right back up.  Any ideas what I'm doing wrong?  Thanks very much in advance...</p>
