Home > Web Front-end > JS Tutorial > body text

How to use jQuery unbind method

清浅
Release: 2019-03-20 10:09:20
Original
2521 people have browsed it

The unbind() method in jQuery is used to remove the event handler of the selected element and terminate the function when the event occurs. It can only unbind the bind method or the event handler registered with the jQuery method

The unbind() method in jQuery is the reverse operation of the bind() method, which means to delete the bound event from each matching element. Next, I will explain the use of the unbind method specifically in the article, which has certain reference value. I hope it will be helpful to everyone

How to use jQuery unbind method

[Recommended courses:jQuery Tutorial

unbind() method introduction

The unbind() method is used to remove all or selected elements The event handler and the execution of the termination function when the event occurs

Note: The unbind method can only unbind the bind method or the event handler registered with the jQuery method. For example, in the following example, you can unbind it through the unbind() method.

$('demo').click(function(){})
Copy after login

However, events registered with the native addEventListener and attachEvent under IE and events bound using the onclick/onmouseover attributes cannot be unbind through unbind. Example:

var demo = document.getElementById('demo');
demo.addEventListener(demo,function(){},false);
demo.onclick = function(){}
Copy after login

unbind() method syntax structure:

$(selector).unbind(event,function)
Copy after login

event refers to one or more events that delete elements and is an optional value. If only this parameter is specified, all functions bound to the specified event will be deleted

function refers to the name of the function that unbinds from the specified event of the element, and is also an optional parameter

Case: The background color changes when the div is clicked, but the background color does not change when the delete event is clicked





 
 
 
 

Copy after login

Rendering:

How to use jQuery unbind method

Summary: The above is the entire content of this article. I hope it will be helpful for everyone to learn the unbind method in jQuery.

The above is the detailed content of How to use jQuery unbind method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!