Changing onclick attribute using replace with jQuery

前端 未结 3 1849
终归单人心
终归单人心 2020-12-18 11:15

Do someone know what is the best way to replace some string inside a onclick attribute ?
I need to get the current value and replace some text inside pa

3条回答
  •  [愿得一人]
    2020-12-18 12:02

    You can do this: http://jsfiddle.net/SJP7k/

    var atr = $('a').attr('onclick');
    var str = atr.split('1');
    var natr = str.join('2');
    $('a').attr('onclick',natr);
    

提交回复
热议问题