关于表单的jQuery练习

时间:2023-03-08 16:13:33
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>获取和失去焦点</title>
<meta name="author" content="Administrator" />
<script type="text/javascript" src="script/jquery-1.12.2.js"></script>
<style type="text/css">
table {
margin: auto;
}
table td {
text-align: center;
}
fieldset {
text-align: center;
}
div{
margin: auto 40%;
}
</style>
<!-- Date: 2016-04-02 -->
</head>
<body>
<form action="#" method="post">
<div>
<fieldset>
<legend>
个人基本信息
</legend>
<table>
<tr>
<td><label for="username">名称:</label></td>
<td>
<input type="text" id="username" />
</td>
</tr>
<tr>
<td><label for="pass">密码:</label></td>
<td><input type="password" id="pass" /></td>
</tr>
<tr>
<td><label for="msg">详细信息:</label></td>
<td><textarea id="msg" rows="10" cols="22"></textarea></td>
</tr>
<tr>
<td colspan="2">
<input type="button" id="big" value="放大" />
<input type="button" id="small" value="缩小" />
</td>
</tr>
</table>
</fieldset>
</div>
</form>
<script type="text/javascript">
$(function(){
var $comment = $("#msg");
$("#big").click(function() {
if(!$comment.is(":animated")){
if($comment.height()<500){
$comment.animate({height:"+=50"},0);
}
}
});
$("#small").click(function() {
if(!$comment.is(":animated")){
if($comment.height()>50){
$comment.animate({height:"-=50"},0);
}
}
});
});
</script>
</body>
</html>