[SO] Hide div on click except self.

Code that hides a div when the user clicks on any other element apart from the div itself. Example for http://stackoverflow.com/users/389271/android-nick

by Khez

HTML

<div id="test">I'm gonna hide!</div>

CSS

#test{
    background-color:#000;
    color:#fff;
}

JavaScript

$(function(){
    $('#test').click(function(event){
        event.stopPropagation();
    });
    $(document).click(function(){
        $('#test').hide();
    });
});