1. 程式人生 > >jQuery val() - 獲取值

jQuery val() - 獲取值

alert text 測試 jquery libs charset set test lib

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
alert("值為: " + $("#test").val());
});
});
</script>
</head>

<body>
<p>名稱: <input type="text" id="test" value="測試"></p>
<button>顯示值</button>
</body>
</html>

jQuery val() - 獲取值