<html>
<head>
<meta charset="utf-8">
<title>Demo</title>
<script src="
https://cdn.bootcss.com/jquery/1.8.0/jquery.js "></script></head>
<body>
<input id="myText" type="text"/>
<button onclick="getVal()">获取值</button>
<script type="text/javascript">
function getVal(){
var myVal= document.getElementById("myText").value;
alert('文本框的值为:'+myVal);
}
</script>
</body>
</html>