JQuery dynamically removes the method of increasing the onclick attribute

The instance of this paper tells the method of jQuery dynamic removal and increasing the onclick property. Share to everyone for reference, specifically:

Here you introduce Removeattr with ATTR event to add a tag to the A tab and delete the onclick event. Operation method, friends who need to understand can be referred to.

To achieve the effect: Click the link first to remove the onclick property first, and then automatically add the onClick property in this tab in 3 seconds

jQuery, the operation of the label attribute It is achieved by Attr () , such as $ ("a"). Attr ("onclick") can get A tag onclick Attribute, corresponding:

$ (selector) .attr (Property Name) It is to get the specified element ($ (selector) section The value of the specified attribute

Setting an OnClick property:

 $ ("a"). Attr ("onclick", "test ();   
Delete event

$ (Selector) .removeattr (Attribute)
 , for example, deleting an OnClick property:  
$ (“a”). Removeattr (“onclick”);

Theoretically, the code is no problem, but in fact, the above statement does not execute it, then discovering the cause:
  jquERY 1.6 The previous version does not support  attr () 
method for the Tag OnClick property!
In other words, use the onClick property in the ATTR () method Operation Tag must use the JQ library 1.6 or updated library version!

$ (Function () {$ (“function () {$ (this) .removeattr (“OnClick”); setTimeout (“on () {$ (“. b “). attr (” onclick “,” test (); “);}, 3000)}) Function test () {}

Click on the onclick property to remove the link, then automatically add this onclick property after 3 seconds
     jQuery deletion attribute Key words: removeAttr Note A is uppercase  

jQuery also has a method of lifting an event delegate: unbind ([evenettype]) . The parameters are optional, if not, indicate all binding events that remove the node.

Here you only need to release the Click event, you can use
$ ("# S1"). UNBIND ("Click")
.
More about JQuery Related Contents Readers can view this topic: “jQuery common event usage and skill summary”, “jQuery common plugin and usage summary”, “jQuery operation JSON data skills summary”, “JQuery extension skill summary”, “jQuery Common Classic Special Effects Summary” and “JQuery Selector Summary”

I hope this article will help you jQuery program.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment