Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cfadc8f

Browse files
Merge pull request #53 from AzharAli-github/main
DOM-Child-Nodes
2 parents 7474b73 + 979cfd3 commit cfadc8f

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
h2 {
2+
font-family: monospace;
3+
}
4.15 KB
Loading[フレーム]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<title>DOM Nodes</title>
9+
<link rel="stylesheet" href="css/style.css">
10+
<link rel="shortcut icon" href="images/js-logo.png" type="image/x-icon">
11+
</head>
12+
13+
<body>
14+
<div class="container">
15+
<h1>DOM Nodes</h1>
16+
<h2>Example One</h2>
17+
<p id="id1">Hello world</p>
18+
<p id="id2"></p>
19+
<button onclick="DisplayOne()">Click</button>
20+
<h2>Example Two</h2>
21+
<p id="textOne">Hello</p>
22+
<p id="textTwo">Azhar</p>
23+
<button onclick="DisplayTwo()">Click</button>
24+
<h2>Example Three</h2>
25+
<p id="textThree">How are you</p>
26+
<p id="textFour">Azhar</p>
27+
<p id="textFive"></p>
28+
<button onclick="DisplayThree()">Click</button>
29+
30+
</div>
31+
<script src="script.js"></script>
32+
</body>
33+
34+
</html>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Child Nodes and Values
2+
let id1 = document.getElementById('id1');
3+
let id2 = document.getElementById('id2');
4+
5+
function DisplayOne() {
6+
id2.innerHTML = id1.firstChild.nodeValue;
7+
}
8+
9+
// Child Nodes and Values Example 2
10+
11+
let textOne = document.getElementById('textOne');
12+
let textTwo = document.getElementById('textTwo');
13+
14+
function DisplayTwo() {
15+
textTwo.innerHTML = textOne.childNodes[0].nodeValue + " " + textTwo.childNodes[0].nodeValue;
16+
}
17+
18+
// Child Nodes and Values Example 3
19+
20+
let textThree = document.getElementById('textThree');
21+
let textFour = document.getElementById('textFour');
22+
let textFive = document.getElementById('textFive');
23+
24+
function DisplayThree() {
25+
textFive.innerHTML = textThree.childNodes[0].nodeValue + textFour.childNodes[0].nodeValue;
26+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /