5.js获取文本框的value值

1.首先通过文本框的使用getElementById("idName");方法来获取文本框对象;

2.通过文本框对象来获取文本款的value值

 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 2 "http://www.w3.org/TR/html4/loose.dtd">
 3 <html>
 4 <head>
 5 <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
 6 <title>无标题文档</title>
 7 <script type="text/javascript">
 8 
 9     function getValue(){
10     
11         var input=document.getElementById("myId");//通过id获取文本框对象
12         alert(input.value);//通过文本框对象获取value值
13     
14     }
15 
16 </script>
17 </head>
18 
19 <body>
20 
21     <input type="button" value="注册" onClick="getValue()"/>
22     <input type="text" id="myId">
23 
24 </body>
25 </html>

 

posted @ 2017-11-20 12:45  xzy不会飞的地板流  阅读(30965)  评论(0编辑  收藏  举报