Changing button color programmatically

后端 未结 7 1791
一整个雨季
一整个雨季 2020-12-16 10:13

Is there a way to change the color of a button, or at least the color of the button label programmatically? I can change the label itself with

document.getE         


        
7条回答
  •  旧时难觅i
    2020-12-16 10:43

    Probably best to change the className:

    document.getElementById("button").className = 'button_color';
    

    Then you add a buton style to the CSS where you can set the background color and anything else.

提交回复
热议问题