Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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>
Comment

PREVIOUS NEXT
Code Example
Javascript :: discord.js create unexipable invite 
Javascript :: checkbox click event jquery 
Javascript :: How to get convert number to decimal - jquery 
Javascript :: how to sum array elements in javascript 
Javascript :: jquery cancel ajax request on click 
Javascript :: js get paste text 
Javascript :: moment is not defined 
Javascript :: javascript play sound onclick 
Javascript :: usenavigate 
Javascript :: how to find the key of an value in an object 
Javascript :: refresh page on back button click javascript 
Javascript :: js get transition duration 
Javascript :: change style of class divs jquery 
Javascript :: convert dict to json python 
Javascript :: mui theme remove shadow 
Javascript :: js add string to beginning of string 
Javascript :: how to run react build locally 
Javascript :: image background full width react 
Javascript :: props.history.push with data 
Javascript :: convert number to k m b javascript 
Javascript :: js rounding 
Javascript :: javascript string first letter lowercase 
Javascript :: rails routes default format json 
Javascript :: js promise all return json array 
Javascript :: sort ip address javascript 
Javascript :: increase-memory-limit not working node 
Javascript :: how to detect the keyboard keys in js 
Javascript :: randomColor 
Javascript :: fullscreen mode javascript 
Javascript :: remove bearer from token in node js 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =