首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

textarea自动伸缩有关问题

2013-11-29 
textarea自动伸缩问题本帖最后由 chate 于 2013-11-27 16:44:03 编辑如下代码在IE浏览器里伸缩自如,但是到

textarea自动伸缩问题
本帖最后由 chate 于 2013-11-27 16:44:03 编辑 如下代码在IE浏览器里伸缩自如,但是到了chrome或FF里,连续回车换行再删除或整段删除文字就不能自动缩短到应有位置了:

<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'">

热点排行