通过jQuery的attr修改onclick(转)

var js = "alert('B:' + this.id); return false;";
// creates a function from the "js" string
var newclick = eval("(function(){"+js+"});");
// clears onclick then sets click
$("#anchor").attr('onclick', '').click(newclick);

来源:changing the value of onclick with or without jQuery

原文地址:https://www.cnblogs.com/shenyixin/p/2875064.html