我想在人们更改内容时获得<textarea>
的滚动高度。问题是当我添加内容时,我可以获得越来越多的滚动高度,但是当我删除内容时,我可以“T这里得到降低scrollheight.And是代码删除内容时无法获得textarea的滚动高度
$("textarea[id^='_sub_ialready_']").live("keydown keyup focus blur",
function()
{
if(aobj.minHeight == 0)
aobj.minHeight = $(this).height();
if($(this).attr("scrollHeight") > aobj.minHeight)
{
if($(this).attr("scrollHeight") > aobj.maxHeight)
{
nheight = aobj.maxHeight;
$(this).css("overflow-Y",'scroll');
}
else
{
nheight = $(this).attr("scrollHeight");
$(this).css("overflow-Y",'hidden');
}
$(this).height(nheight);
}
}
)
你可以指定你的CSS或一点点更多的代码,所以我们可以更好地理解你想要做什么?此外,你有没有检查出有关获取scrollHeight的这些问题?: http://stackoverflow.com/questions/5980150/jquery-js-get-the-scrollbar-height-of-an-textarea http:/ /stackoverflow.com/questions/642353/dynamically-scrolling-a-textarea http://stackoverflow.com/questions/454202/creating-a-textarea-with-auto-resize – elboletaire 2011-12-30 02:31:20