Search code examples
javascriptjqueryhtmlpropagation

jQuery click event stop propagation can't get to work?


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();
});

});

Solution

  • 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;
    });
    

    ?