Use the attr method of jQuery to modify the onclick value, jqueryattr
Okay. paste the js Code directly.
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 ()}); function Test () {alert ("Test passed! "); Return ;}
If it can help you, please step on it.
Use of attr in jquery
The type attribute is read-only.
Yes $ ("input"). hide ()
Or $ ("input"). attr ("style", "display: none ");
Try it.
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 ")')