Change onclick action with a Javascript function

前端 未结 8 1373
刺人心
刺人心 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:43

    You could try changing the button attribute like this:

    element.setAttribute( "onClick", "javascript: Boo();" );
    
    0 讨论(0)
  • 2020-12-02 12:44

    What might be easier, is to have two buttons and show/hide them in your functions. (ie. display:none|block;) Each button could then have it's own onclick with whatever code you need.

    So, at first button1 would be display:block and button2 would be display:none. Then when you click button1 it would switch button2 to be display:block and button1 to be display:none.

    0 讨论(0)
提交回复
热议问题