简体   繁体   中英

Change contents of custom function

I need to change a custom function variable in an anchor link ecample:

<a id="myID" onClick="myFunction(var1, var2, var3);" />

I know I can use $('a#myID').attr('onClick'); to get contents of the onClick event, but how do I change the var3 variable inside that custom function?

Change it around:

<div id="myID">clickable</div>

then in JavaScript:

$('#myID').click(function () {
    // do stuff with var1 var2 and var whatever
});

just do a simple:

value = $('a#myID').attr('onClick');
value.replace("var1", "blah");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM