I have a div that slides down when a button is clicked, and I would like to slide up the div when a user:
EDIT How to create a custom modal popup - and how to close it clicking outside of it
Here, just an example of mine: http://jsbin.com/uqiver/1/edit
$("body").on('click', function(ev) {
var myID = ev.target.id;
if (myID !== 'panel') {
$('#panel').hide();
}
});
Or you can also check if it's visible at first:
var $pan = $('#panel');
$("body").on('click', function(ev) {
if ($pan.is(':visible') && ev.target.id !== 'panel') $pan.hide();
});