Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

DOM-Child-Nodes #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions JavaScript/Advance/DOM/10. DOM Nodes/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
h2 {
font-family: monospace;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions JavaScript/Advance/DOM/10. DOM Nodes/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DOM Nodes</title>
<link rel="stylesheet" href="css/style.css">
<link rel="shortcut icon" href="images/js-logo.png" type="image/x-icon">
</head>

<body>
<div class="container">
<h1>DOM Nodes</h1>
<h2>Example One</h2>
<p id="id1">Hello world</p>
<p id="id2"></p>
<button onclick="DisplayOne()">Click</button>
<h2>Example Two</h2>
<p id="textOne">Hello</p>
<p id="textTwo">Azhar</p>
<button onclick="DisplayTwo()">Click</button>
<h2>Example Three</h2>
<p id="textThree">How are you</p>
<p id="textFour">Azhar</p>
<p id="textFive"></p>
<button onclick="DisplayThree()">Click</button>

</div>
<script src="script.js"></script>
</body>

</html>
26 changes: 26 additions & 0 deletions JavaScript/Advance/DOM/10. DOM Nodes/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Child Nodes and Values
let id1 = document.getElementById('id1');
let id2 = document.getElementById('id2');

function DisplayOne() {
id2.innerHTML = id1.firstChild.nodeValue;
}

// Child Nodes and Values Example 2

let textOne = document.getElementById('textOne');
let textTwo = document.getElementById('textTwo');

function DisplayTwo() {
textTwo.innerHTML = textOne.childNodes[0].nodeValue + " " + textTwo.childNodes[0].nodeValue;
}

// Child Nodes and Values Example 3

let textThree = document.getElementById('textThree');
let textFour = document.getElementById('textFour');
let textFive = document.getElementById('textFive');

function DisplayThree() {
textFive.innerHTML = textThree.childNodes[0].nodeValue + textFour.childNodes[0].nodeValue;
}