Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Change HTML Content in JavaScript

    • 0
    • 2
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 275
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: