Here is something I am trying to do. I have created a jsfiddle so you can look and let me know how to do what I am looking for.
$(document).ready(function() {
$('#trigger-button').click( function () {
$('#trigger-box').toggle();
});
});
It's working fine as far as code is concerned. Clicking on button triggers a box to appear and disappear. Works fine.
But what I want is if someone click button and box appear then the box can disappear by 2 methods.
- clicking again on button or
- click anywhere except box (clicking on page body) <-- this is where i need help.
click. It makes no sense. After that, have a look at jQuery UI dialogs. They probably do what you want. There are also tons of similar libs to show modal dialog windows.