How do you override inline onclick event?

前端 未结 4 1844
暗喜
暗喜 2020-12-02 09:07

This seems deceptively simple.

How do you override the onclick event in the following HTML using JavaScript?



        
4条回答
  •  攒了一身酷
    2020-12-02 09:51

    This can also be done without jQuery:

    document.getElementById("sample").setAttribute('onclick','alert("done")');
    

提交回复
热议问题