当价值增加时,textarea的高度增加,但当价值降低时,textarea的高度不会降低 [英] height of textarea increases when value increased but does not reduce when value is decreased

查看:81
本文介绍了当价值增加时,textarea的高度增加,但当价值降低时,textarea的高度不会降低的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<body>
<script type="text/javascript">$(function(){
$("textarea").live("keyup keydown",function(){var h=$(this);
h.height(h[0].scrollHeight);
});});

</script>
<textarea style="resize:none;width:760px;height:60px; overflow:hidden;" ></textarea>
</body>

当textarea溢出时,它会得到滚动条和scrollheight,并将其应用于其高度,但不适用于减少textarea高度在减少它的值长度,它不会得到滚动条

When textarea get overflowed it get scrollbar and scrollheight which gets applied to its height but not working for decreasing textarea height as on decreasing its value length it doesnot get scrollbar

推荐答案