以前看了JS方面的书,如今用到了,书看得再多,不用就忘了,所以经常用用你所学到的知识,温故知新。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 |
<!DOCTYPE html> <html> <head> <meta http-equiv= "Content-Type"
content= "text/html;charset=utf-8" /> <title> ###</title> <meta keywords= "商品目录" /> <meta description= "JS查找孩子节点" /> <script type= "text/javascript" > function
getContent() { var
x=document.getElementById( "content" ); for ( var
i=0;i<x.childNodes.length;i++) { if ((content=x.childNodes[i].innerHTML)== "目录" ) { var
next=x.childNodes[i].nextSibling.nextSibling.textContent; alert(next); } } } window.onload=getContent; </script> </head> <body> <div id= "content" > <h3>商品</h3> <div id= "1" > <p > this
is the first paragragh</p> </div> <h3>作者</h3> <div id= "2" > <p> this
is the second paragragh</p> </div> <h3>目录</h3> <div id= "3" > <p> this
is the third paragragh</p> </div> </div> </body> </html> |
还需要努力和实践,坚持,加油。
原文:http://www.cnblogs.com/xshang/p/3580759.html