Skip to main content

Posts

Showing posts with the label hide a div

Solution - Hide a div when user clicked outside of it using jQuery

Solution - Hide a div when user clicked outside of it using jQuery If you want to hide an element like listbox, div or dropdown or any html element when click outside of it but not hide when click inside of it then we can do this by using simple jquery code Please use below code to hide an element on outside click. $(document).mouseup(function(e)   {       var containerElem = $("#list-request-suggestion"); //YOUR ELEMENT ID OR CLASS       if (!containerElem.is(e.target) && containerElem.has(e.target).length === 0)       {           containerElem.hide();       }   });   Related Links Hide a div when clicked outside of it How do I detect a click outside an element ? How to hide div on outside click except one inside div through jquery   html - Use jQuery to hide a DIV when the user clicks out...