JavaScript使表單中的內(nèi)容顯示在屏幕上的方法
本文實(shí)例講述了JavaScript使表單中的內(nèi)容顯示在屏幕上的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
一、使內(nèi)容水平出現(xiàn)
<html> <head> <title>測(cè)試</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>
二、使內(nèi)容以表格形式出現(xiàn)
<html> <head> <title>測(cè)試</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>
希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。
相關(guān)文章
js+SVG實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘效果
這篇文章主要為大家詳細(xì)介紹了js+SVG實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-07-07利用404錯(cuò)誤頁面實(shí)現(xiàn)UrlRewrite的實(shí)現(xiàn)代碼
要求:網(wǎng)站編碼為utf-8,不適用于GB2312; 替換字符的正則可以自己增加和修改,以適合自己的網(wǎng)站;2008-08-08javascript 操作符(~、&、|、^、<<、>>)使用案例
這篇文章主要介紹了javascript 操作符(~、&、|、^、<<、>>)使用案例,非常的全面,需要的朋友可以參考下2014-12-12List the Codec Files on a Computer
List the Codec Files on a Computer...2007-06-06input鏈接頁面、打開新網(wǎng)頁等等的具體實(shí)現(xiàn)
input可以鏈接到某頁、返回、打開新網(wǎng)頁、打開無邊框的新窗口等等,本文整理了一些,感興趣的朋友可以參考下2013-12-12