1. 程式人生 > >js中獲取input中所輸入的值

js中獲取input中所輸入的值

-c scrip tle utf-8 element 輸入 pla ont button

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
</head>

	<script type="text/javascript">

		function huoqu(){

			var G=document.getElementById(‘value‘).value;

			alert(G);

		}

	</script>

	<body>

		<div class="containter">

			<div class="row">

				<div class="md-col-12">

				<input type="text" id="value" placeholder="要獲取的輸入的值"/>

				<input type="button" value="打印" onclick="huoqu()"/>

				</div>

			</div>

		</div>

	</body>


</html>

  

js中獲取input中所輸入的值