您的位置:首页 > 其它

textarea自动增长宽高

2014-04-15 09:05 405 查看
<script type="text/javascript">

$(function(){
$("#iptcont").bind("keydown",function(e){
var key = e.which,that = this,h = 20;
if (key == 13) {
var brs = $(this).val().split("\n").length+1;
$(this).attr("rows",brs).height(h*brs);
}else if(key == 8){
window.setTimeout(function(){
var brs = $(that).val().split("\n").length;
$(that).attr("rows",brs).height(h*brs);
},100);
}

});
});
</script>
<body>
<textarea id="iptcont" rows="1" style="border:none;height:20px;border-bottom:1px solid blue;width:200px;resize:none;font-size:18px;line-height:20px;overflow:hidden;"></textarea>
</body>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: