JS document练习
来源:互联网 发布:软件测试未来发展方向 编辑:程序博客网 时间:2024/05/04 13:05
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function shownode() {
var ohtml = document.documentElement;
//alert(ohtml.nodeName);
//alert(ohtml.childNodes.length);
//alert(ohtml.childNodes[1].nodeName); //获取body
//var obody = ohtml.childNodes[1];//如果你愿意癮一层一层一层剥开ahtml的心,就可以找到div
var obody = ohtml.lastChild; //快速获取ohtml的最后一个子节点?
//alert(obody.childNodes[0].nodeName);
//alert(obody.parentNode.nodeName);//根据子节点找到想要的父节点?
alert(obody.previousSibling.nodeName);
var ohead = ohtml.childNodes[0];
alert(ohead.nextSibling.nodeName);
}
</script>
</head>
<body>
<div id="div1">第一层</div>
<div id="div2">
第二层</div>
<div>
第三层
<img src="images/4.jpg" />
</div>
<div>
第四层<input id="Button1" type="button" value="显示节点" onclick="shownode();"/></div>
</body>
</html>
- JS document练习
- document.js
- js document
- Document.selection相应练习
- document对象练习
- js的document问题
- Document对象详解 (JS)
- Document对象详解 (JS)
- js - Tree of Document
- js中的document对象
- js document详解
- js document.getElementById $()
- js:document.write()方法
- JS: document,window
- js document属性集合
- JS Document对象
- js document用法
- js document.createElement()
- JS 窗口间图片轮行效果练习
- Gamebryo—Progrmming
- Fuck MySQL (2) Linux环境下MySQL用户登陆命令
- 初试picture控件
- 回车和换行的区别
- JS document练习
- 大 学 十 年 励志
- wait for a undo record模拟和解决
- 关系型数据库基础之:组合查询
- 58同城姚劲波:以域名起家 从创业小子到亿万富翁
- 危机过后,雷军为小米寻找新“同盟”?
- UTMS 信令培训(16)
- Linux目录文件操作
- Makefile编写------------实例演示