【js練習一】マウスを使って画像と画像の説明を切り替えます.


   
   
   
   
  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.     }