我想在人們更改內容時獲得<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