The jQuery attr method modifies the onclick value and jquery modifies the attr value.
The jQuery attr method modifies the onclick value.
The onclick value is modified through the attr of jQuery.
Code:
Var js = "alert ('B:' + this. id); return false; "; var newclick = eval (" (function () {"+ js +"}); "); $ (" # anchor "). attr ('onclick ',''). click (newclick );
If the onclick event has a value, clear it first, and then assign a value using click (eval (function () {...}).
$ ("Input [name = 'ordercar']"). attr ('onclick ',''). click (eval (function () {Test ()}); // www. jbxue. comfunction Test () {alert ("Test passed! "); Return ;}
In IE7, jqueryattr ("onclick", "function () {}") is not supported. I hope JS can help solve this problem. Thank you! The attr method of jQuery adds attributes to the specified object. First, there should be an object, such
: $ ("# Div"). attr (); then the onclick attribute cannot add a function, because onclick itself is an attribute of javascript, so it cannot be a function when assigned a value. You can assign a value to the function body!
$ ("# Btn"). attr ('onclick', 'alert ("dddd ")')
The type attribute of attr in jquery is read-only.
Yes $ ("input"). hide ()
Or $ ("input"). attr ("style", "display: none ");
Try it.