删除内容时无法获取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);
}
}
)
I want to get the scrollheight of <textarea>
when people changing the content.The problem is when I add the content ,I can get a growing scrollheight ,but when I delete contents,I can't get a Reduced scrollheight。And here is the code
$("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);
}
}
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您要做的就是首先将高度设置为 auto,如下所示:
然后获取scrollHeight 属性:
What you want to do is set height to
auto
first, like so:Then get the scrollHeight property:
怎么样...
OR
OR(返回以像素为单位的整数)
What about...
OR
OR (returns an integer in pixels)