1:DOM的学习
- 一份文档就是一棵节点树;
- 节点分为不同的类型:元素节点,属性节点,文本节点;
- getElementById返回的是一个对象;
- getElementByTagName和getElementByclassName返回的是一个对象数组,分别对应着文档中一个特定的元素节点;
- 每个节点都是一个对象;
- getAttribute获取属性节点的值
- setAttribute设置属性节点的值
例子:`这里写代码片
“http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
Image Gallery
Snapshots
Choose an image.
function showPic(whichpic) { var source = whichpic.getAttribute("href"); var placeholder = document.getElementById("placeholder"); placeholder.setAttribute("src",source); var text = whichpic.getAttribute("title"); var description = document.getElementById("description"); description.firstChild.nodeValue = text; }
`