jQuery: Unbind jQuery 2.0 on method

In jQuery 1.9 live() was deprecated, so the new method became:

$(document).on("mouseover","*",blahblahfunc);

I'm unable to unbind "blahblahfunc". via

$("*").unbind("mouseover mouseout click");

Notice that I'm binding a function to every element in the dom, any ideas?

Answers:

Answer

use .off()

see the Api Documentation

http://api.jquery.com/off/

The off() method removes event handlers that were attached with .on()

$(document).on("mouseover","*",blahblahfunc);
$(document).off("mouseover","*",blahblahfunc);
Answer

The opposite of $("selector").on(...) is $("selector").off(...). See http://api.jquery.com/off/ Hope that helps.

Answer

You bound the event to the document, therefore you have to unbind it from the document.

$(document).off("mouseover","*",blahblahfunc);

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.