Answers for "document.getElementByClassName("").innerText"

1

js document.getelementsbyclassname modify innertext

<body>

<p class="demo">JavaScript can change the content of an HTML element.</p>    
<p class="demo">Yolo</p>   

<button type="button" onclick="myFunction()">Click Me!</button>

<script>        
function myFunction()
{
x=document.getElementsByClassName("demo");  // Find the elements
    for(var i = 0; i < x.length; i++){
    x[i].innerText="Hello JavaScript!";    // Change the content
    }

}

</script>
</body>
Posted by: Guest on March-25-2020

Code answers related to "document.getElementByClassName("").innerText"

Code answers related to "Javascript"

Browse Popular Code Answers by Language