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?

Sinister Beard
  • 3,570
  • 12
  • 59
  • 95

1 Answers1

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

Parth Trivedi
  • 3,802
  • 1
  • 20
  • 40
Justinas
  • 41,402
  • 5
  • 66
  • 96