Get the App
SLTechnology News&Howtos  ›  Development  › 

How jquery unbinds events bound to on ()

Shulou Source: shulou.com Published: 2022-06-01 03:04:04 09月15日 Update

This article mainly explains "how jquery unbinds the event of on ()". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the event of how jquery unbinds on ()".

Cancellation method: 1, the use of off () function, this function can remove the event handler added through on (), the syntax "bind the element of the event. Off ()"; 2, the use of unbind () function, the function can delete any jq method to add the event handler, syntax "bind the event element .unbind ();".

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

Jquery unbinds the event of on ()

Method 1: use the off () function

The off () function is typically used to remove event handlers added by the on () method.

$(document) .ready (function () {$("p") .on ("click", function () {$(this) .ready ();}) ("button") .click (function () {$("p") .off ();});})

This is a paragraph.

This is another paragraph.

Click on any paragraph to make it disappear. Including this paragraph.

Remove events added by on ()

2. Use the unbind () function

The unbind () function removes the event handler for the selected element.

Ubind () applies to any event handler attached through jQuery.

$(document) .ready (function () {$("p") .on ("click", function () {$(this) .ready ();}) ("button") .click (function () {$("p") .unbind ();});})

This is a paragraph.

This is another paragraph.

Click on any paragraph to make it disappear. Including this paragraph.

Remove events added by on ()

Thank you for reading, the above is the content of "how jquery unbinds the event of on ()". After the study of this article, I believe you have a deeper understanding of the problem of how jquery cancels the event of on () binding, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Events functions paragraphs programs processes methods this is elements learning content grammar that is ideas situations tutorials articles more versions environments computers Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux vpn Shulou Technology Microsoft Shulou Tech Info