Answers for "getelementbyid change style"

9

how to change style of an element using javascript

<html>
<body>

<p id="p2">Hello World!</p>

<script>
document.getElementById("p2").style.color = "blue";
</script>

<p>The paragraph above was changed by a script.</p>

</body>
</html>
Posted by: Guest on January-10-2020
1

how to change css using javascript

document.getElementById("myText").className = "anyNewClass"
Posted by: Guest on August-02-2020
0

change style by getelementby tag name

var x = document.getElementById("myDIV");
var y = x.getElementsByTagName("P");
var i;
for (i = 0; i < y.length; i++) {

    y[i].style.backgroundColor = "red";
}
Posted by: Guest on August-16-2021

Code answers related to "getelementbyid change style"

Code answers related to "Javascript"

Browse Popular Code Answers by Language