jQuery + Not Selector

Posted by Andrej on Stack Overflow See other posts from Stack Overflow or by Andrej
Published on 2011-11-15T17:44:35Z Indexed on 2011/11/15 17:51 UTC
Read the original article Hit count: 479

Being a newbie to Javascript and jQuery, I am not sure whether this is not possible at all or I am just doing a completely dumb mistake:

I am trying to hide a div on any click outside the div itself.

I have simplified the code for demonstration purpose:

HTML

<html>
    <div class="tooltip">
        Bla Bla Bla
    </div>
</html>

jQuery

$('html:not(.tooltip)').click(function() {

    $('.tooltip').hide();

});

Demo

http://jsfiddle.net/yCx6F/1/

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors