Home > Article > Web Front-end > JavaScript method to display the content in the form on the screen_javascript skills
The example in this article describes the method of using JavaScript to display the content in the form on the screen. Share it with everyone for your reference. The specific implementation method is as follows:
1. Make the content appear horizontally
<html> <head> <title>测试</title> <script type="text/javascript"> function to() { var txt=document.getElementById("txt").value; document.getElementById("a").innerHTML+=txt; } </script> </head> <body> <div id="a">在这里显示:</div> <button onclick="to();">输入</button> </body> </html>
2. Make the content appear in table form
<html> <head> <title>测试</title> <script type="text/javascript"> function to() { var txt=document.getElementById("txt").value; var row=document.getElementById("ib").insertRow(); row.align="center"; var tt0=row.insertCell(); tt0.innerHTML=txt; } </script> </head> <body> <div id="a"></div> <table id="ib"> <tr> <th>content</th> </tr> </table> <input type="text" id="txt" value="" size="30"> <button onclick="to();">输入</button> </body> </html>
I hope this article will be helpful to everyone’s JavaScript programming design.