Press "Enter" to skip to content

InnerHTML Example in JavaScript

Defintion :

Inner HTML is a property which is meant for displaying the html content internally within in the html tags.

Program :

<html>

   <head>  

      <script language=”javascript”>

                    function display()

                                {

                                  a=parseFloat(document.getElementsByTagName(“input”)[0].value);

                                  b=parseFloat(document.getElementsByTagName(“input”)[1].value);

                                  c=a+b;

                                  //document.write(“<h1> <center> sum=”+c+” </center> </h1>”)

                                  document.getElementById(“dd”).innerHTML=”<h1> <center>sum=”+c+”</center> </h1>”;

                                 }

                                 </script>

                </head>

                 <body>

                                 <center>

                                   <input type=”text” name=”t1″/> <br>

                                   <input type=”text” name=”te”/> <br>

                                   <input type=”button” value=”First Button” onClick=”display()”/>

                                   <div id=”dd”> </div>

                                 </center>

                 </body>

</html>

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *