I’m having a little trouble with this JQuery function.
Basically, I have a div, that when clicked, shows another Div. It’s set to a toggle, actually, so it toggles on/off when you click.
I want to have it where if you click on anywhere outside of the opened div (that appears after you click on the first div), the div that was opened is closed.
$("#idSelect").click(function() {
$("#idDiv").toggle();
});
EDIT : A better approach here:
How to create a custom modal popup – and how to close it clicking outside of it
jsBin demo