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

Jquery method to replace event that already exists on element_jquery

WBOY
Release: 2016-05-16 18:32:46
Original
1111 people have browsed it

Look at the code below:

Copy the code The code is as follows:


< ;meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
TestPage








Use unbind, then removeAttr, and finally add your method. Let’s take a look at their API document:
unbind([type], [fn])
Overview
The reverse operation of bind() removes the bound event from each matching element.
If there are no parameters, delete all bound events.
You can unbind the custom event you registered with bind().
If an event type is provided as a parameter, only bound events of that type will be removed.
If the handler function passed when binding is used as the second parameter, only this specific event handler will be deleted.
Parameters
type (optional) String
Event type
fn (optional) Function
Event handler function to unbind from the event of each matched element
removeAttr (name)
Overview
Remove an attribute from each matching element
Parameters
nameString
The name of the attribute to be deleted
Simply:
Copy code The code is as follows:

$("#someelement").unbind('eventname').removeAttr('event ').click(function() {
//your new method.
});

Hope this is helpful to you.
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 admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template