Dom编程艺术3-className

1.元素属性信息

parentNode、nextSibling(是下一个节点,不一定是元素节点)、previousSibling、childNodes、firstChild、lastChild
还有 element.style.property

2.style 对外部样式表里申明的样式不会进入style对象,在head中的也一样

但是我们可以用dom来设置样式然后在用dom把他们读取出来

3. 为元素设置样式

function styleHeaderSiblings() {
  if (!document.getElementsByTagName) return false;
  var headers = document.getElementsByTagName("h1");
  for (var i=0; i
  
    

Hold the front page

This first paragraph leads you in.

Now you get the nitty-gritty of the story.

The most important information is delivered first.

Extra! Extra!

Further developments are unfolding.

You can read all about it here.

Dom编程艺术3-className_第1张图片
Paste_Image.png

3.隔行变色

function stripeTables() {
  if (!document.getElementsByTagName) return false;
  var tables = document.getElementsByTagName("table");
  for (var i=0; i

  
Itinerary
When Where
June 9th Portland, OR
June 10th Seattle, WA
June 12th Sacramento, CA
Dom编程艺术3-className_第2张图片
Paste_Image.png

你可能感兴趣的:(Dom编程艺术3-className)