<!DOCTYPE html>
<html>
<style>
.democlass {color: red;}
</style>
<body>
<h1>malay</h1>
<p>"Add " buttom को click करने पर heading का color change .</p>
<button onclick="myFunction()">Add</button>
<script>
function myFunction() {
// Create a class attribute:
const att = document.createAttribute("class");
// Set a value of the class attribute
att.value = "democlass";
// Add the class attribute to the first h1;
document.getElementsByTagName("h1")[0].setAttributeNode(att);
}
</script>
</body>
</html>
malay
"Add " buttom को click करने पर heading का color change .

कोई टिप्पणी नहीं