Home  >  Article  >  Web Front-end  >  JavaScript method to display the content in the form on the screen_javascript skills

JavaScript method to display the content in the form on the screen_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:52:241297browse

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn