Parents and Siblings of an Element

 <!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Parents and Siblings of an Element</title>
</head>

<!-- First child of body -->
<body><div><div class="first">first</div><div class="second">second</div></div>
    <script src="../Parents_Siblings_of_an_Element.js"></script>
</body>

</html>





Below File is Parents_Siblings_of_an_Element.js File.
console.log(document.body.firstChild);
a = document.body.firstChild;
console.log(a.parentNode);
console.log(a.parentElement);
console.log(a.firstChild.nextSibling);







Comments

Popular posts from this blog

Generators tutorial in Advance JavaScript

Document Object Module DOM querySelector and querySelectorAll tutorial in JavaScript

Find Even and Odd Numbers with Loops tutorial in JavaScript