GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — java/professional-javascript/Ch12/TreeWalkerExample2.htm at master · luoyonggit/java

Expand file tree

/

TreeWalkerExample2.htm

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
39 lines (33 loc) · 1.46 KB
/

TreeWalkerExample2.htm

Copy path

File metadata and controls

39 lines (33 loc) · 1.46 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<!DOCTYPE html>
<html>
<head>
<title>TreeWalker Example</title>
<script type="text/javascript">
function makeList() {
var div = document.getElementById("div1");
var walker = document.createTreeWalker(div, NodeFilter.SHOW_ELEMENT, null, false);
var output = document.getElementById("text1");
walker.firstChild(); //go to <p>
walker.nextSibling(); //go to <ul>
var node = walker.firstChild(); //go to <li>
while (node !== null) {
output.value += node.tagName + "\n";
node = walker.nextSibling();
}
}
</script>
</head>
<body>
<p><strong>Note:</strong> The <code>TreeWalker</code> object has only been implemented in Internet Explorer 9, Chrome, Opera (version 7.6 and higher), Safari (version 1.3 and higher), and Firefox (version 1.0 and higher). It has not been implemented in Internet Explorer 8 or earlier (so this example won't work).</p>
<div id="div1">
<p>Hello <b>World!</b></p>
<ul>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ul>
</div>
<textarea rows="10" cols="40" id="text1"></textarea><br />
<input type="button" value="Make List" onclick="makeList()" />
</body>
</html>
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.