jQuery实现textarea自动增长宽高的方法
本文实例讲述了jQuery实现textarea自动增长宽高的方法。分享给大家供大家参考,具体如下:
<scripttype="text/javascript">
$(function(){
$("#iptcont").bind("keydown",function(e){
varkey=e.which,that=this,h=20;
if(key==13){
varbrs=$(this).val().split("\n").length+1;
$(this).attr("rows",brs).height(h*brs);
}elseif(key==8){
window.setTimeout(function(){
varbrs=$(that).val().split("\n").length;
$(that).attr("rows",brs).height(h*brs);
},100);
}
});
});
</script>
<body>
<textareaid="iptcont"rows="1"style="border:none;height:20px;border-bottom:1pxsolidblue;width:200px;resize:none;font-size:18px;line-height:20px;overflow:hidden;"></textarea>
</body>
希望本文所述对大家jQuery程序设计有所帮助。
热门推荐
1 潜能开发训练狗狗
2 狗狗多会训练好
3 扣篮训练狗狗
5 狗狗不训练
6 少儿柔术训练狗狗
8 训练好狗狗
9 训练狗狗怎么训
10 狗狗训练猫咪
11 狗狗训练地点
12 两个多月的狗狗怎么训练
13 怎么训练狗狗去厕所拉屎
14 狗狗怎样训练大小便
15 训练狗狗母
16 怎么训练狗狗坐下和握手
17 近视训练狗狗
18 狗狗倒的训练