tolga
tolga

Reputation: 2830

How can I unbind an event for an element which comes with AJAX

My javascript binds an event to a specific element like this:

$(document).on('click', '.element-class', function() {
   binding_function();
}

I need to bind this way, since the element is on the content which comes with AJAX.

I tried to unbind:

$(".element-class").unbind();

But this doesn't work. How can I unbind this?

Upvotes: 0

Views: 40

Answers (2)

tolga
tolga

Reputation: 2830

OK, I found a solution.

$(document).off('click', '.tab-more-link');

Upvotes: 0

user2908232
user2908232

Reputation: 451

Check .off, it's the counterpart of .on, you can find the documentation here: http://api.jquery.com/off/ . .unbind is the counterpart of .bind, so that didn't work here.

Upvotes: 1

Related Questions