Selectors in javascript dom manipulation:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Selector in javascript</title>
</head>
<body>
<a href="asd">asdasd</a>
<div class="container">
<ul id="nav">
<li><a href=""></a>Home</li>
<li>About</li>
<li>Services</li>
<li>Contact</li>
</ul>
</div>
<div class="container">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsum repellat quidem tenetur?</p>
</div>
</body>
<script>
let nav = document.getElementById("nav");
// console.log(nav.innerHTML = "<p>This is the test text</p>")
console.log(nav.anchors.length)
// class selector in javascript.... class ke saab element print kar denga
let cllass = document.getElementsByClassName("container");
// console.log(cllass)
// agar apko khali first wala do dekhna hai to aap array ki tarah dekh sakte hai
// console.log(cllass[0])
// agar apko khali ek hi child class first class ko hi access karna hai to aap queryselector ko use kar sakte hai
let first_child = document.querySelector(".container");
// ye wala ((sabse pahila wala element ko return kar denga
console.log(first_child);
// agar apko sare class ko ek sath fetch karna hai to aap
let all_class_data = document.querySelectorAll(".container");
console.log(all_class_data);
</script>
</html>
Thanks you for commenting your questions. I will see question and respond you.