RE: an example for innerHTML and getElementById

    I need an example how can i use innerHTML and getElementbyId to store the data in to element.

    Add Comment
    1 Answers
      
      <!doctype html>
      
      <html>
      
      <head>
      
      <meta charset="utf-8">
      
      <title>Updating,Adding Content into Elements using Javascript</title>
      <style type="text/css">
      
      .conc{
      
      font-size:50px;
      
      }
      
      #cont{
      
      color:#33E300;
      
      }
      
      </style>
      
      <script type="text/javascript">
      document.write("<p class='conc'>India</p>");
      function runmyjavaScript(){
      var cc = document.getElementById('cont');
      
      cc.innerHTML = "I love India";
      }
      
      </script>
      </head>
      <body onLoad="runmyjavaScript()">
      
      <p id="cont"></p>
      
      </body>
      
      </html>
      
      Kid Answered on March 7, 2016.
      Add Comment

      Your Answer

      By posting your answer, you agree to the privacy policy and terms of service.