0
0 Comments

How to use Javascript Reference – HTML DOM getElementsByClassName() Method.

The following code shows how to get all elements with HTML DOM getElementsByClassName() using specified class name.
here is my cod

<!DOCTYPE html>
<html>
<body>
<div class="live">One</div>
<div class="live">Two</div>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
    var x = document.getElementsByClassName("live");
    x[0].innerHTML = "Testing!";
}
</script>
 </body>
</html>


i change id to class and try using getElementsByClassName the function stops working.

Changed status to publish
Add a Comment