代码如下:
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);
// creates a function from the "js" string
var newclick = eval( " (function(){ " + js + " }); " );
// clears onclick then sets click
$( " #anchor " ).attr( ' onclick ' , '' ).click(newclick);