欢迎您 本站地址:
复制网址
手机查看
切换背景
返回首页
返回编程教学
人间清醒
三国演义
猜谜语
少儿英语书籍
男生头像少年
CMS建站源码
春秋战国
学习Go
源代码:
html编辑器
颜色值转换
点击运行
<script> // 获取元素节点的上一个同级节点 function get_previoussibling(n) { x=n.previousSibling; while (x.nodeType!=1) { x=x.previousSibling; } return x; } xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.getElementsByTagName("author")[0]; document.write(x.nodeName); document.write(" = "); document.write(x.childNodes[0].nodeValue); y=get_previoussibling(x); document.write("<br>Previous sibling: "); document.write(y.nodeName); document.write(" = "); document.write(y.childNodes[0].nodeValue); </script>
运行结果:
小库提示
扫描下方二维码,访问手机版。
打赏
关闭