Home > Web Front-end > JS Tutorial > Use jQuery's attr method to modify the onclick value_jquery

Use jQuery's attr method to modify the onclick value_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:42:19
Original
1720 people have browsed it

Okay, let’s just paste the js code for everyone

var js = "alert('B:' + this.id); return false;"; 
var newclick = eval("(function(){"+js+"});"); 
$("#anchor").attr('onclick', '').click(newclick);
Copy after login

If the onclick event originally had a value, it must be cleared first and then assigned using click( eval(function(){.....}) )

$("input[name='orderCar']").attr('onclick','').click( eval(function(){Test()})); 

function Test(){ 
alert("测试通过!"); 
return; 
}
Copy after login

If I can help you, please step on me hard down there.

Related labels:
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