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>
<div class="live">One</div>
<div class="live">Two</div>
<button onclick="myFunction()">test</button>
function myFunction() {
    var x = document.getElementsByClassName("live");
    x[0].innerHTML = "Testing!";

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

Changed status to publish
Add a Comment