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 cancels the live event

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "jquery how to cancel the live event". The content of 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 "how jquery cancels the live event".

In jquery, the die () method can be used to cancel the live event, which removes the specified event bound by the live () method, and the syntax "$(selector) .die (" event name "," handler name ")"; both parameters of the die () method can be omitted, thus removing all bound live events.

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

Use the die () method to cancel the live event.

The die () method removes one or more event handlers added to the selected element through the live () method.

Simply put, the die () method removes the specified event bound by the live () method.

Syntax:

The $(selector) .die (event,function) parameter description event is optional. Specifies one or more event handlers to remove.

Multiple event values are separated by spaces. Must be a valid event. Function is optional. Specifies the specific function to remove.

Note: the die () method is deprecated in jQuery version 1.7 and removed in version 1.9.

Example 1: remove all through the live () method to

Event handlers added by the

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

This is a paragraph.

This is another paragraph.

Click on any paragraph to make it disappear.

Remove the click event

The click event of the p element is added by the live () method

Example 2: use the die () method to remove only one specified event handler from the selected element

Function changeSize () {$(this) .animate ({fontSize: "+ = 3px"}) } function changeSpacing () {$(this) .animate ({letterSpacing: "+ = 2px"}) } $(document) .ready (function () {$("p"). Live ("click", changeSize); $("p") .live ("click", changeSpacing) $("button") .click (function () {$("p") .die ("click", changeSize);})

This is a paragraph.

This is another paragraph.

Click on any paragraph to enlarge the font.

Remove the event handle changeSize (), and the click event of the p element is added by the live () method.

Thank you for reading, the above is the content of "jquery how to cancel the live event". After the study of this article, I believe you have a deeper understanding of how jquery cancels the live event, 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