且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何以编程方式更改div的样式

更新时间:2023-10-02 13:54:28

如果要使用浏览器中运行的客户端代码(javascript)更改div的颜色,请执行以下操作:

If you want to alter the color of the div with client side code (javascript) running in the browser, you do something like the following:

<script>
 var fooElement = document.getElementById("foo");
 fooElement.style.color = "red"; //to change the font color
</script>