document对象:
1.直接操作:
对象.属性 = 值;
如下面一段代码:
<a href = "...">跳转</a>
<script>
var a = document.getElenmentsByTagName("a")[0];//注意这里的TagName是个数组,所以用数组的方式填写;
a.href = "...";
a.className = "...";
a.getAttribute("href");//获取值;
a.setAttribute("href","3.html");//设置值;
</script>
2.document的样式操作:
div.style.backgroundColor = "black";
div.style.color = "white";
3.使用hover:
a.mouseover = function () {
this.style.backgroundColor = "red";
};
a.onmouseout = function () {
this.style.color = "blue";//this指鼠标正在指的这个..
};
document.styleSheets[index].rule[index].style.属性;
document.styleSheets[index].cssRules[index].style.属性;(FF);
获取最终样式:
var div1 = document.getElementById("div1");
<script>
alert(div1.currentStyle.width);(IE)
//alert(window.getcoputeStyle(div1,null)[width]); other