获得匹配元素的当前值,常应用于表单元素,select....,可读可写
实例:
<!DOCTYPE html>
<html lang='zh-cn'>
<head>
<title>Insert you title</title>
<meta http-equiv='description' content='this is my page'>
<meta http-equiv='keywords' content='keyword1,keyword2,keyword3'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- <script type='text/javascript' src='./js/jquery-3.0.0.js'></script> -->
<script type='text/javascript' src='./js/jquery-1.12.1.min.js'></script>
<style type='text/css'>
input{font:400 13px/20px 'Courier New';color:#000;}
.addOne{padding:0 8px;}
.addTwo{color:#999;}
button[type='button']{font:400 13px/1.2em 'Courier New';padding:3px;}
</style>
<script type='text/javascript'>
$(function(){
$('button').click(function(){
alert($('#user').val());
$('#user').val('this is a test');
});
});
</script>
</head>
<body>
<input type='text' id='user' required="required" value='user' class='addOne addTwo'/>
<button type='button'>toggleClass</button>
</body>
</html>