Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 15:52:24
Original
1296 people have browsed it

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>

Copy after login

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>

Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!