基于jQuery实现文本框缩放以及上下移动功能
想让你的网页更加的炫酷,想让你的留言评论更加的具有互动性吗,那么请仔细研究下本代码吧。
jQuery代码:
$(function(){
var$comment=$('#comment');
$('.bigger').click(function(){
if(!$comment.is(":animated")){
if($comment.height()<500){
//$comment.height($comment.height()+50);
$comment.animate({height:"+=50"},400);
}
}
});
$('.smaller').click(function(){
if(!$comment.is(":animated")){
if($comment.height()>50){
//$comment.height($comment.height()-50);
$comment.animate({height:"-=50"},400);
}
}
});
$('.up').click(function(){
if(!$comment.is(":animated")){
$comment.animate({scrollTop:"-=50"},400);
}
});
$('.down').click(function(){
if(!$comment.is(":animated")){
$comment.animate({scrollTop:"+=50"},400);
}
});
});
HTML代码:
<divclass="msg">
<divclass="msg_caption">
<spanclass="bigger">放大</span>
<spanclass="smaller">缩小</span>
<spanclass="up">向上</span>
<spanclass="down">向下</span>
</div>
<div>
<textareaid="comment"rows="8"cols="20">
水电费水电费爽肤水法萨芬沙发放松放松沙发
当爽肤水飞沙发发沙发发发发
水电费水电费爽肤水法萨芬沙发放松放松沙发
当爽肤水飞沙发发沙发发发发
</textarea>
</div>
</div>
CSS代码:
.bigger,.down,.up,.smaller{
background-color:#f1a55c;
}
代码奉上,具体如何使用,使用在何处,我就不多说了,小伙伴们自由发挥吧。
热门推荐
10 小红书平安祝福语简短
11 生日祝福语大全女孩简短
12 收生日红包祝福语 简短
13 领证幽默祝福语简短
14 法考面试祝福语简短
15 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语