I have a div that I want to show when a button is clicked, and then if in another place on the page (including the original button), except that the hidden div is clicked, I want the div to hide again.
I think I'm pretty close, just can't understand. This is what I still have (as a basic example:
$(".clickme").click(function () { $(".toggletag").addClass('open'); }); if ( $('.toggletag').hasClass('open') ) { $("html").click(function () { $(".toggletag").removeClass('open'); }); }
Here is a JSfiddle using this code: http://jsfiddle.net/vgf6g/1/
I tried without an if statement first, but that of course made html click to override the button click, causing the div to never show.
Thanks!
jquery hide show
Bluecaret
source share