jQuery实现textarea自动增长宽高的方法
本文实例讲述了jQuery实现textarea自动增长宽高的方法。分享给大家供大家参考,具体如下:
<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>
希望本文所述对大家jQuery程序设计有所帮助。
相关推荐
zengni 2020-04-16
Vipwxs 2018-12-19
javaer 2008-09-02
jscjxysx 2019-07-01
冯二爷 2019-07-01
Donutsapps 2019-06-29
无情 2018-12-19
87281248 2017-09-28
原為簡單 2017-09-28
web开发 2017-01-16
勤能补拙孰能生巧 2019-06-28
wndong 2015-12-14
shishaoe 2015-04-10
csstpeixun 2015-04-02
xiaocaibai 2014-12-19
realitycss 2014-05-05
DreamLee 2013-12-13
切慕溪水 2013-07-11
lkj0 2013-05-24