如何用 document.style 设置 背景色 & 字体
<div id="term_commodity"><a href="#" onclick="term_commodity_focus()">商品</a></div><div id="term_shop"><a href="#" onclick="term_shop_focus()">店铺</a></div>
<script>
function term_shop_focus(){
document.getElementById("term_commodity").style.background-color="#0099ff";
document.getElementById("term_shop").style.background-color="#033ff";
//document.getElementById("term_commodity").style.font-weight="normal";
document.getElementById("term_commodity").style.color="#0000ff";
}
function term_commodity_focus(){
document.getElementById("term_shop").style.background-color="#0000ff";
document.getElementById("term_commodity").style.background-color="#2200ff";
//document.getElementById("term_shop").style.font-weight=normal;
document.getElementById("term_shop").style.color="#0000ff";
</script>
如何实现? --------------------编程问答-------------------- css不行吗 --------------------编程问答-------------------- 你这样已经实现了改变样式呀,你还要实现什么,如果要改变div的内容,就加上document.getElementById("term_commodity").innerHtml('内容') --------------------编程问答-------------------- 你自己不是贴出来了吗? --------------------编程问答-------------------- backgroundColor --------------------编程问答-------------------- fontWeight --------------------编程问答-------------------- //document.getElementById("term_commodity").style.font-weight="normal";
这一句 会报错
其他的 全都实现不了 ????? --------------------编程问答--------------------
5楼的参照下 还有这个可以到w3cschool里面去查看 里面有些相关的说明 当JS操作CSS样式时。 --------------------编程问答-------------------- document.getElementById("dv").style.backgroundColor="";
document.getElementById("dv").style.fontWeight="";
--------------------编程问答-------------------- 路过......... --------------------编程问答-------------------- js中style属性下面的具体样式名都不带“-”的,比如background-color在js中应为backgroundColor,font-weight在js中应为fontWeight。 --------------------编程问答-------------------- 学习啦!帮顶! --------------------编程问答-------------------- backgroundColor --------------------编程问答-------------------- document.getElementById("dv").style.backgroundColor="";
--------------------编程问答-------------------- js中style属性下面的具体样式名都不带“-”的,比如background-color在js中应为backgroundColor,font-weight在js中应为fontWeight。
补充:.NET技术 , ASP.NET