0

I want to prevent this function from working:

$(document).on("click",".filters", function(event) {
    $('.filters').removeClass('selectedFilter');
    $(this).addClass('selectedFilter');
    $('.filters div').not('.selectedFilter div').slideUp(200);
    $('.selectedFilter div').animate({opacity:"toggle",height:"toggle"},200);
});

I've tried $(".filters").unbind("click"), but that's not working, I'm guessing because of how I trigger it in the first place?

4

1 回答 1

4

Try off instead of unbind

$(document).off("click", ".filters");

From the documentation:

The .off() method removes event handlers that were attached with .on() and Event handlers attached with .bind() can be removed with .unbind()

于 2016-01-12T12:14:28.703 回答