Change onclick action with a Javascript function

前端 未结 8 1397
刺人心
刺人心 2020-12-02 12:14

I have a button:


When I click this button the first time, I want it to exe

8条回答
  •  广开言路
    2020-12-02 12:40

    Your code is calling the function and assigning the return value to onClick, also it should be 'onclick'. This is how it should look.

    document.getElementById("a").onclick = Bar;
    

    Looking at your other code you probably want to do something like this:

    document.getElementById(id+"Button").onclick = function() { HideError(id); }
    

提交回复
热议问题