hide div when click outside not working with oveflow scroll

Home / Uncategorized / hide div when click outside not working with oveflow scroll

Question:
hello trying to hide div menu when clicking outside the div i use worked just fine but my div using css oveflow scroll and when i clicked in scroll the div closing , here’s my jquery code is
$(document).ready(function() {
$(".button").click(function(event) {
event.stopPropagation();
$(‘.mymenu’).show();

});
$(document).mouseup(function(d) {
var container = $(".sub");
if (!container.is(d.target) && container.has(d.target).length === 0) {

$(‘.mymenu’).hide();
}
});
});
.mymenu has css option oveflow:scroll is there anyway make the div not closing when click on scroll inside


Answer:
Your event is firing for each click on the document. Can’t you do a more accurate event ? You could for example add a wrapper child in .mymenu and do something like that
$(‘.mymenu .mymenu-wrapper’).mouseup(function(d) {
$(‘.mymenu’).hide();
});
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *