码迷,mamicode.com
首页 > 其他好文 > 详细

点击按钮获得文本框里面的值

时间:2015-05-12 20:29:26      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

<script type="text/javascript">

  window.onload = function(){

      var obtn=document.getElementById("Button2");

      obtn.onclick = function(){

      alert(document.getElementsById("Text2").value);

   };

}

</script>

 

    <p>用户名:<input id="Text2" type="text" value="用户名"/><input id="Button2" type="button" value="获得用户名"/></p>

或者:

   <p>用户名:<input id="Text2" type="text" value="用户名"/><input id="Button2" type="button" value="获得用户名" onclick="javascript:alert(document.getElmentById(Text2).value);"/></p

点击按钮获得文本框里面的值

标签:

原文地址:http://www.cnblogs.com/lissa/p/4498247.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!