-->

Thursday, June 26, 2025

JavaScript Program to Use querySelector() – DOM Manipulation in JS with Examples

 


JS DOM programs collection



JS program to show the concept of querySelector()

<!-- In JavaScript, 
querySelector() is a method provided by the DOM (Document Object Model) that allows you to select the first HTML element that matches a specified CSS selector. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>DOM (queryselector)</title>
</head>
<body>
<p id="id1">hello DOM</p>
<script>
var txt;
txt=document.querySelector('#id1');
txt.style.color="green";
</script>

</body>
</html>

No comments:

Post a Comment