Vincent Roye Vincent Roye - 1 year ago 118
HTML Question

jQuery click anywhere in the page except on 1 div

How can I trigger a function when I click anywhere on my page except on one div (id=menu_content) ?

Thank you very much

Answer Source

You can apply click on body of document and cancel click processing if the click event is generated by div with id menu_content, This will bind event to single element and saving binding of click with every element except menu_content

       if( == "menu_content")
       //For descendants of menu_content being clicked, remove this check if you do not want to put constraint on descendants.

      //Do processing of click event here for every element except with id menu_content

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download