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

 

相关文章:

  • 2021-07-09
  • 2021-06-17
  • 2022-12-23
  • 2021-08-03
  • 2021-06-24
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-29
  • 2021-07-27
  • 2022-02-19
  • 2022-12-23
  • 2021-10-04
  • 2022-12-23
相关资源
相似解决方案