首页 > 其他 > 详细

文本域高度的动态变化

时间:2016-05-16 14:26:28      阅读:166      评论:0      收藏:0      [点我收藏+]
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:
技术分享

运行:
技术分享

文本域高度的动态变化

原文:http://www.cnblogs.com/theWayToAce/p/5497875.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!