I am currently facing an issue with the following code snippet
$(".menu").on('click', function(e) {
e.preventDefault();
$(this).addClass("open").children("div").slideDown(200);
});
$(document).on('click', ".menu.open", function(e) {
e.preventDefault();
$(this).removeClass("open").children("div").slideUp(200);
});
Whenever I click on the .menu
element, the inner div slides down but immediately slides up again and the open class is removed. This happens upon a single click. How can I resolve this issue and make it function properly as a drop-down menu for small screens - opened by a click and closed by another click?