Javascript examples for jQuery Method and Property:off
Remove event handler from <p> element
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> function changeSize() {/*from w w w. j av a 2 s . co m*/ $(this).animate({fontSize: "+=3px"}); } function changeSpacing() { $(this).animate({letterSpacing: "+=2px"}); } $(document).ready(function(){ $("body").on("click", "p", changeSize); $("body").on("click", "p", changeSpacing); $("button").click(function(){ $("body").off("click", "p"); }); }); </script> </head> <body> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <p>Click any p element to increase size and letterspacing.</p> <button>Remove all click event handlers</button> </body> </html>