{"id":2946,"date":"2015-11-19T16:11:30","date_gmt":"2015-11-19T15:11:30","guid":{"rendered":"https:\/\/www.ice-dev.com\/non-classifiee\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/"},"modified":"2015-11-19T16:11:30","modified_gmt":"2015-11-19T15:11:30","slug":"how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery","status":"publish","type":"post","link":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/","title":{"rendered":"How to detect a click everywhere except on a specific HTML element in jQuery"},"content":{"rendered":"<p>To detect a click everywhere except on a specific div and its content in jQuery, here is the code to insert.<br \/>\nThe code below will hide the element with the ID #my_div when clicking anywhere else.<br \/>\nThis is very useful if your element contains, for example, a login form&#8230;<\/p>\n<p><script src=\"https:\/\/gist.github.com\/reficedev\/a41c43db15310c508675.js\"><\/script><\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ice-dev.com\/wp-content\/uploads\/2015\/11\/clic-partout-ailleurs-jquery.jpg\" alt=\"clic-partout-ailleurs-jquery\" width=\"1081\" height=\"530\" class=\"alignnone size-full wp-image-274\" srcset=\"https:\/\/www.ice-dev.com\/wp-content\/uploads\/2015\/11\/clic-partout-ailleurs-jquery.jpg 1081w, https:\/\/www.ice-dev.com\/wp-content\/uploads\/2015\/11\/clic-partout-ailleurs-jquery-300x147.jpg 300w, https:\/\/www.ice-dev.com\/wp-content\/uploads\/2015\/11\/clic-partout-ailleurs-jquery-1024x502.jpg 1024w\" sizes=\"auto, (max-width: 1081px) 100vw, 1081px\" \/><figcaption>\nExample of use: closing a submenu by clicking anywhere other than on it.<br \/>\n<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Detect a click everywhere except on a specific DIV or a specific HTML element in jQuery.<\/p>\n","protected":false},"author":3,"featured_media":2008,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"kia_subtitle":"","footnotes":""},"categories":[51],"tags":[],"class_list":["post-2946","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-html-css-js-integration"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to detect a click everywhere except on a specific HTML element in jQuery - Ice Development<\/title>\n<meta name=\"description\" content=\"Detect a click everywhere except on a specific DIV or a specific HTML element in jQuery.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to detect a click everywhere except on a specific HTML element in jQuery - Ice Development\" \/>\n<meta property=\"og:description\" content=\"Detect a click everywhere except on a specific DIV or a specific HTML element in jQuery.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/\" \/>\n<meta property=\"og:site_name\" content=\"Ice Development\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ice.development\" \/>\n<meta property=\"article:published_time\" content=\"2015-11-19T15:11:30+00:00\" \/>\n<meta name=\"author\" content=\"joffrey HABAI\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@icedevelopment\" \/>\n<meta name=\"twitter:site\" content=\"@icedevelopment\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"joffrey HABAI\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/html-css-js-integration\\\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/html-css-js-integration\\\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\\\/\"},\"author\":{\"name\":\"joffrey HABAI\",\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/#\\\/schema\\\/person\\\/a294e21c005621f7bfa260d4315e1b8f\"},\"headline\":\"How to detect a click everywhere except on a specific HTML element in jQuery\",\"datePublished\":\"2015-11-19T15:11:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/html-css-js-integration\\\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\\\/\"},\"wordCount\":77,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/html-css-js-integration\\\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.ice-dev.com\\\/wp-content\\\/uploads\\\/2015\\\/11\\\/logo-jquery.svg\",\"articleSection\":[\"HTML\\\/CSS\\\/JS integration\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/html-css-js-integration\\\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/html-css-js-integration\\\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\\\/\",\"url\":\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/html-css-js-integration\\\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\\\/\",\"name\":\"How to detect a click everywhere except on a specific HTML element in jQuery - Ice Development\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/html-css-js-integration\\\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/html-css-js-integration\\\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.ice-dev.com\\\/wp-content\\\/uploads\\\/2015\\\/11\\\/logo-jquery.svg\",\"datePublished\":\"2015-11-19T15:11:30+00:00\",\"description\":\"Detect a click everywhere except on a specific DIV or a specific HTML element in jQuery.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/html-css-js-integration\\\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/html-css-js-integration\\\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/html-css-js-integration\\\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.ice-dev.com\\\/wp-content\\\/uploads\\\/2015\\\/11\\\/logo-jquery.svg\",\"contentUrl\":\"https:\\\/\\\/www.ice-dev.com\\\/wp-content\\\/uploads\\\/2015\\\/11\\\/logo-jquery.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/html-css-js-integration\\\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/ice-development\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to detect a click everywhere except on a specific HTML element in jQuery\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/#website\",\"url\":\"https:\\\/\\\/www.ice-dev.com\\\/\",\"name\":\"Ice Development\",\"description\":\"agence web Lyon\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.ice-dev.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/#organization\",\"name\":\"Ice Development\",\"url\":\"https:\\\/\\\/www.ice-dev.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.ice-dev.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/apple-touch-2.png\",\"contentUrl\":\"https:\\\/\\\/www.ice-dev.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/apple-touch-2.png\",\"width\":512,\"height\":512,\"caption\":\"Ice Development\"},\"image\":{\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/ice.development\",\"https:\\\/\\\/x.com\\\/icedevelopment\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/ice-development-lyon\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.ice-dev.com\\\/#\\\/schema\\\/person\\\/a294e21c005621f7bfa260d4315e1b8f\",\"name\":\"joffrey HABAI\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d1da0aa2d703657405601e50bb799d38f69eabad25b226f9c236f84ce7447d38?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d1da0aa2d703657405601e50bb799d38f69eabad25b226f9c236f84ce7447d38?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d1da0aa2d703657405601e50bb799d38f69eabad25b226f9c236f84ce7447d38?s=96&d=mm&r=g\",\"caption\":\"joffrey HABAI\"},\"url\":\"https:\\\/\\\/www.ice-dev.com\\\/en\\\/author\\\/jhabai\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to detect a click everywhere except on a specific HTML element in jQuery - Ice Development","description":"Detect a click everywhere except on a specific DIV or a specific HTML element in jQuery.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/","og_locale":"en_US","og_type":"article","og_title":"How to detect a click everywhere except on a specific HTML element in jQuery - Ice Development","og_description":"Detect a click everywhere except on a specific DIV or a specific HTML element in jQuery.","og_url":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/","og_site_name":"Ice Development","article_publisher":"https:\/\/www.facebook.com\/ice.development","article_published_time":"2015-11-19T15:11:30+00:00","author":"joffrey HABAI","twitter_card":"summary_large_image","twitter_creator":"@icedevelopment","twitter_site":"@icedevelopment","twitter_misc":{"Written by":"joffrey HABAI"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/#article","isPartOf":{"@id":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/"},"author":{"name":"joffrey HABAI","@id":"https:\/\/www.ice-dev.com\/#\/schema\/person\/a294e21c005621f7bfa260d4315e1b8f"},"headline":"How to detect a click everywhere except on a specific HTML element in jQuery","datePublished":"2015-11-19T15:11:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/"},"wordCount":77,"commentCount":0,"publisher":{"@id":"https:\/\/www.ice-dev.com\/#organization"},"image":{"@id":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/#primaryimage"},"thumbnailUrl":"https:\/\/www.ice-dev.com\/wp-content\/uploads\/2015\/11\/logo-jquery.svg","articleSection":["HTML\/CSS\/JS integration"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/","url":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/","name":"How to detect a click everywhere except on a specific HTML element in jQuery - Ice Development","isPartOf":{"@id":"https:\/\/www.ice-dev.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/#primaryimage"},"image":{"@id":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/#primaryimage"},"thumbnailUrl":"https:\/\/www.ice-dev.com\/wp-content\/uploads\/2015\/11\/logo-jquery.svg","datePublished":"2015-11-19T15:11:30+00:00","description":"Detect a click everywhere except on a specific DIV or a specific HTML element in jQuery.","breadcrumb":{"@id":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/#primaryimage","url":"https:\/\/www.ice-dev.com\/wp-content\/uploads\/2015\/11\/logo-jquery.svg","contentUrl":"https:\/\/www.ice-dev.com\/wp-content\/uploads\/2015\/11\/logo-jquery.svg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.ice-dev.com\/en\/html-css-js-integration\/how-to-detect-a-click-everywhere-except-on-a-specific-html-element-in-jquery\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.ice-dev.com\/en\/ice-development\/"},{"@type":"ListItem","position":2,"name":"How to detect a click everywhere except on a specific HTML element in jQuery"}]},{"@type":"WebSite","@id":"https:\/\/www.ice-dev.com\/#website","url":"https:\/\/www.ice-dev.com\/","name":"Ice Development","description":"agence web Lyon","publisher":{"@id":"https:\/\/www.ice-dev.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.ice-dev.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.ice-dev.com\/#organization","name":"Ice Development","url":"https:\/\/www.ice-dev.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.ice-dev.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.ice-dev.com\/wp-content\/uploads\/2023\/06\/apple-touch-2.png","contentUrl":"https:\/\/www.ice-dev.com\/wp-content\/uploads\/2023\/06\/apple-touch-2.png","width":512,"height":512,"caption":"Ice Development"},"image":{"@id":"https:\/\/www.ice-dev.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ice.development","https:\/\/x.com\/icedevelopment","https:\/\/www.linkedin.com\/company\/ice-development-lyon\/"]},{"@type":"Person","@id":"https:\/\/www.ice-dev.com\/#\/schema\/person\/a294e21c005621f7bfa260d4315e1b8f","name":"joffrey HABAI","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d1da0aa2d703657405601e50bb799d38f69eabad25b226f9c236f84ce7447d38?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d1da0aa2d703657405601e50bb799d38f69eabad25b226f9c236f84ce7447d38?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d1da0aa2d703657405601e50bb799d38f69eabad25b226f9c236f84ce7447d38?s=96&d=mm&r=g","caption":"joffrey HABAI"},"url":"https:\/\/www.ice-dev.com\/en\/author\/jhabai\/"}]}},"_links":{"self":[{"href":"https:\/\/www.ice-dev.com\/en\/wp-json\/wp\/v2\/posts\/2946","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ice-dev.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ice-dev.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ice-dev.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ice-dev.com\/en\/wp-json\/wp\/v2\/comments?post=2946"}],"version-history":[{"count":0,"href":"https:\/\/www.ice-dev.com\/en\/wp-json\/wp\/v2\/posts\/2946\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ice-dev.com\/en\/wp-json\/wp\/v2\/media\/2008"}],"wp:attachment":[{"href":"https:\/\/www.ice-dev.com\/en\/wp-json\/wp\/v2\/media?parent=2946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ice-dev.com\/en\/wp-json\/wp\/v2\/categories?post=2946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ice-dev.com\/en\/wp-json\/wp\/v2\/tags?post=2946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}