function a(){

    alert("a");

}

 

function b(){

    alert("b");

}

 

<input type="button" onclick="a()" />

 

要将buttononclick改为b()方法,最保险的做法是:

$("input[type=button]").removeAttr("onclick").attr("onclick","b()");

在不同浏览器中(ie),很有可能直接给onclick赋值并不能取代前方法,先移除onclick再添加,有利于浏览器的兼容性。

相关文章:

  • 2022-12-23
  • 2021-11-18
  • 2021-10-14
  • 2021-06-15
  • 2021-11-02
  • 2021-11-28
猜你喜欢
  • 2021-12-02
  • 2022-12-23
  • 2021-08-05
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
相关资源
相似解决方案