I’m working on a menu that should slide down when I click on an anchor <a>, and it should slide up when I click on the <body> of the page (the <a> tag is included in the body).
I’m currently using jQuery.
The problem is that after the first 2 click’s (first on the tag result: the menu appears; second click on the <body>), the menu disappears, but when I click again on the <a> tag the menu slides both down an up at the same time?
Here is the code:
$(function() {
$('.sch_option a').click(function() {
$('.sch_option .sch_more_option_extend').slideDown(150, function(){
$('body').click(function() {
$('.sch_option .sch_more_option_extend').slideUp(100);
});
});
});
});
When you click on the a, you need to stop propagation of the click event.