jQuery click event stop propagation can't get to work? [closed]
-
20-04-2021 - |
문제
I've got a popup that I don't want to close unless you click off of it, however it closes whenever I click on it as well. It shouldn't close when you click inside the div with the class of "create-album-container"
$(document).ready(function() {
////posts menu
$(".container").on("contextmenu", ".photos-bottom .albums li", function(e) {
var id = $(this).attr("id");
e.stopPropagation();
e.preventDefault;
$('.create-album-container').hide();
$('.photos-bottom .albums li#'+id+' .create-album-container').show();
return false;
});
$("body").click(function (event) {
$('.create-album-container').hide();
});
});
해결책
Should be e.preventDefault();
- it is a function
And did you try to add
$('.create-album-container').click(function(e){
e.preventDefault();
e.stopPropagation();
return false;
});
?
제휴하지 않습니다 StackOverflow