Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How jquery unbinds events bound to on ()

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report