Hide div on click outside using jquery
Today, we are going to explain to you how to hide div on click outside using jquery. sometimes we have to need hide div when the user clicks outside of this div.
You can easily hide div or element on click outside using jquery. so you can see our below jquery click outside snippet code.
In this example, we are used .mouseup() event. when the user clicks outside then the event occurs and that time we will check the click detect element id. if will any found then we will hide it.
1 2 3 4 5 6 7 8 | <script> $(document).mouseup(function(e){ var eti = $("#element_target_id"); if(!eti.is(e.target) && eti.has(e.target).length === 0){ eti.hide(); } }); </script> |
Read Also: Disable Browser Back Button Using Jquery
Please follow and like us: