Why isn't this working - using :not() with an event handler

Posted by james emanon on Stack Overflow See other posts from Stack Overflow or by james emanon
Published on 2012-06-05T22:19:29Z Indexed on 2012/06/05 22:40 UTC
Read the original article Hit count: 88

Filed under:
|

I seem to have another issue that I am not conquering. Real simple premise. I have a mousedown event, and basically IF one particular element on the page is clicked, I want nothing to happen, else I want hide() some div.

    $(function(){
        $("document :not(#_ignorelement)").mousedown(function(event){
                if($('#_hidethiselement').length){
                    $('#_hidethiselement').hide();
                }
        })
     })

That is not working at all. I also tried the following:

    $(document).not($("#_ignorelement")).mousedown(function(event){

    $(document).not("_ignorelement").mousedown(function(event){

IF I can solve that, curious how I would actually have ":not" encompass the parent div, like so:

$().not("_ignoreelement").parent().closest('div').mousedown(function

Because the element "_ignorelement" is an anchor tag that is in a div. Wonder how I can use the parent div perhaps, instead of the anchor tag.

Anyways, any help would be appreciated.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery