【js練習一】マウスを使って画像と画像の説明を切り替えます.
3790 ワード
- function showPic(whichpic){
- whichpic.getAttribute("href"); //
- var source = whichpic.getAttribute("href"); //
- var placeholder = document.getElementById("placeholder"); // ,
- placeholder.setAttribute("src",source); //
- var text = whichpic.getAttribute("title"); // whichpic title ,
- var description = document.getElementById("description"); // id description
- description.firstChild.nodeValue = text; // text id=description nodeValue
- }
-
- window.onload = countBodyChildren; // countBodyChildren
-
- function countBodyChildren(){
- var body_element = document.getElementsByTagName("body")[0];// body ,
- //alert(body_element.childNodes.length); // body
- //alert(body_element.nodeType); //
- // 1
- // 2
- // 3
- //alert(description.nodeValue); // description
- //alert(description.childNodes[0].nodeValue); //
- //alert(description.firstChild.nodeValue); //
- //alert(description.lastChild.nodeValue); //
- }