1.     function showPic(whichpic){ 
  2.         whichpic.getAttribute("href"); //把占位图换成想要的图片 
  3.         var source = whichpic.getAttribute("href"); //把路径存入变量 
  4.         var placeholder = document.getElementById("placeholder"); //获取占位图,赋值 
  5.         placeholder.setAttribute("src",source); // 设置占位符的属性和值 
  6.         var text = whichpic.getAttribute("title");  //获取whichpic 的title值,赋值 
  7.         var description = document.getElementById("description"); //定义id为description 
  8.         description.firstChild.nodeValue = text;  //用变量text去刷新id=description的第一个子节点的nodeValue属性值 
  9.     } 
  10.  
  11. window.onload = countBodyChildren;  //页面加载时调用countBodyChildren 
  12.  
  13.     function countBodyChildren(){ 
  14.         var body_element = document.getElementsByTagName("body")[0];//得到body元素,返回数组元素第一个元素 
  15.          //alert(body_element.childNodes.length); //查出body一共几个子元素 
  16.         //alert(body_element.nodeType); //节点属性值 
  17.         //元素节点 1 
  18.         //属性节点 2 
  19.         //文本节点 3 
  20.         //alert(description.nodeValue);  //得到description节点的值 
  21.         //alert(description.childNodes[0].nodeValue);   //得到

    元素的第一个子节点 

  22.         //alert(description.firstChild.nodeValue); //第一个元素 
  23.         //alert(description.lastChild.nodeValue);  //最后一个元素 
  24.     }