以编程方式更改按钮颜色 [英] Changing button color programmatically
本文介绍了以编程方式更改按钮颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法以编程方式更改按钮的颜色,或者至少更改按钮标签的颜色?
我可以用
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.getElementById("button").object.textElement.innerText = "newlabel";
但是如何改变颜色?
推荐答案
我终于找到了一个正常工作的代码 - 试试这个:
I have finally found a working code - try this:
document.getElementById("button").style.background='#000000';
这篇关于以编程方式更改按钮颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文