javascript——textarea自动伸缩问题

来源:互联网 发布:管家婆软件怎么安装 编辑:程序博客网 时间:2024/05/22 13:02

原文链接:http://bbs.csdn.net/topics/390653996

如下代码在IE浏览器里伸缩自如,但是到了chrome或FF里,连续回车换行再删除或整段删除文字就不能自动缩短到应有位置了:

JavaScript code
?
1
2
3
4
5
<textarea name="textarea" id="textarea" 
style='overflow-y: hidden;height:20px' 
onpropertychange="this.style.height = this.scrollHeight + 'px';" 
oninput="this.style.height = this.scrollHeight + 'px';">
</textarea>

有办法解决吗?


<textarea name="textarea" id="textarea" style='height:20px' onpropertychange="this.style.height = this.scrollHeight + 'px';"  oninput="this.style.height='auto';this.style.height = this.scrollHeight + 'px'">

0 0
原创粉丝点击