I have a header with a drop-down, div, notification field ( #container) that switches to a slide. JavaScript for dropdown:
$("a.trigger").click(function (event) {
$('#container').slideToggle(100)
event.preventDefault();
});
I also have a function that closes the div field if I click anywhere outside #container:
$(document).mouseup(function (e) {
var container = $('#container');
if (!container.is(e.target)) {
container.hide();
}
});
When I click on a.trigger, it lowers #container, and then if I click anywhere outside #container, it correctly closes it. But when I click a.trigger, while it is #containeralready open, it closes it from the second javascript function, as it a.triggeris outside #container, but then the first function starts too late and #containerslidestoggles down again immediately after hiding it.
Here is the fiddle: http://jsfiddle.net/Hx65Q/1013/
, , , javascript , . ? ?