With the help of this javascript function we can change the html content of an element., when we will click on button it will manipulate the DOM (change HTML contents).
<p class="demo">Hello everyone </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=" Hii this is JavaScript function "; // Change the content
}
}
</script>
0 Comment(s)