- Posted on
- educationidol
- No Comments
- 2.1 CSS Selector
- 312 Views
Appears awesome difference between class and id selector
<!-- Appears awesome difference between class and id selector. -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Id in Javascript</title>
</head>
<body>
<div>
<p id="a">There is applying formatting.</p>
<p id="a">There is no effect because we are using id selector.</p>
<script>
document.getElementById('a').style.backgroundColor = "red";
</script>
</div>
</body>
</html>
Show output :