I have some DIV
that fades in by clicking another DIV trigger element. I cannot came up with a script that will:
- On mouse leave then click outside -fade out the
DIV
Thanks for any advice.
I have some DIV
that fades in by clicking another DIV trigger element. I cannot came up with a script that will:
DIV
Thanks for any advice.
If i understood you correctly, this is what you want:
$(document).ready(function(){
var button = $("#div1");
var container = $("#div2");
button.on('click', function(){
container.fadeIn();
});
$(document).mouseup(function (e){
// check if click target is element or one of its children
if (!container.is(e.target) && container.find(e.target).length == 0){
container.fadeOut();
}
});
});
Here's the fiddle: http://jsfiddle.net/neQuK/