文本域高度的动态变化

HTML:
<!DOCTYPE >

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style type="text/css">
* {
/*margin: 0px;
padding: 0;*/
font-family: "微软雅黑", "arial", " sans-serif";
font-size: 16px;
}

body {
margin: 20px;
}
</style>
<script type="text/javascript" src="js/jquery-2.2.2.min.js">
</script>

<script type="text/javascript">
$(function () {
var oComment = $("#comment");
$(".bigger").click(function () {
if (!oComment.is(":animated")) {
if (oComment.height() < 500) {
oComment.animate({height: "+=50"}, 400);
}
}
})

$(".smaller").click(function () {
if (!oComment.is(":animated")) {
if (oComment.height() > 50) {
oComment.animate({height: "-=50"}, 400);
}
}
})


});
</script>
</head>

<body>
<form action="" method="post">
<div class="msg">
<div class="msg_caption">
<span class="bigger">向下(+)</span>
<span class="smaller">向上(-)</span>
</div>
</div>
<textarea id="comment" rows="8" cols="25">
在线文本编辑器.在线文本编辑器.在线文本编辑器.
在线文本编辑器.在线文本编辑器.在线文本编辑器.
在线文本编辑器.在线文本编辑器.在线文本编辑器.
在线文本编辑器.在线文本编辑器.在线文本编辑器.

</textarea>
</form>

</body>

</html>

result:

运行:

原文地址:https://www.cnblogs.com/theWayToAce/p/5497875.html