Via Lattanzio,23 Milano
+39 02 36592025
info@synaptica.info

How to Hide Div when Click Outside of the Element using jQuery

Digital solution partner

How to Hide Div when Click Outside of the Element using jQuery

Hide element on click outside, is a must-have functionality for the dropdown menu. Apart from that, it also used in some situations where you need to hide div when the user clicks outside of this element. You can easily hide div or element when click outside of it using jQuery.

In the example code snippet, we will show how to hide element on click outside using jQuery.The div will be hidden when the user clicks on outside of this element.

Use jQuery mouseup event (.mouseup()) with target property (event.target) to detect click event and hide div when clicking outside of the specific element.

Reference https://www.codexworld.com/how-to/hide-div-when-click-outside-of-element-using-jquery/