Saved X
Google login
SignUp with Email
X

Javascript setattribute

theindreshverma ( Edited  Sep 30, 12:32 am )
Login

Javascript setAttribute() method

<h2 align="center">Javascript setattribute</h2>

<style>
.demo{
    color: red;
}
</style>

<p id="p">This is p tag.</p>

<button onclick="setAttr()">Set attribute</button>

<script>
function setAttr() {
    document.getElementById("p").setAttribute("class", "demo");
}
</script>

Sourcecode Tags

More Sourcecodes

More Sourcecodes