标签:
<html> <head> <title>获取文本框中的value</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script language="javascript"> function getUsername(){ //思路:获取文本框节点;获取文本框节点的value //通过元素的id获取元素节点 //document内置对象,属于DOM对象,一下变成属于DOM编程 var usernameInput = document.getElementById("username"); //input文本框中有value属性,所以可以使用这种语法:元素对象.value var username = usernameInput.value; alert(username); } </script> </head> <body> <input type = "text" id = "username" /> <input type = "button" value = "提交" onclick = "getUsername();"/> </body> </html> </html>
标签:
原文地址:http://www.cnblogs.com/wangqiang4518/p/5724253.html