jQuery / JS获取textarea的滚动条高度 [英] jQuery / JS get the scrollbar height of an textarea

查看:116
本文介绍了jQuery / JS获取textarea的滚动条高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个固定高度的textarea。当用户在文本区域中键入文本时,用户在其中键入一些文本后会显示滚动条。

I've got a textarea with a fixed height. When the user types text into the textarea a scrollbar will show up after the user typed some text in it.

如何使用jQuery或纯JavaScript获取滚动条高度?我已经搜索了好几个小时,但找不到任何东西。我不能只插入div并通过div偏移获得滚动条高度,因为textarea不允许有子元素。

How can I get the scrollbar height using jQuery or plain JavaScript? I've been searching for this for hours, but couldn't find anything. I can't just insert a div and get the scrollbar height via the div offset because a textarea is not allowed to have child elements.

请不要给我一个链接到完成工作的jQuery插件。我想学点东西。

Please don't give me a link to a jQuery Plug-In that does the job. I want to learn something.

推荐答案

textarea.scrollHeight

返回一个整数(像素)

这篇关于jQuery / JS获取textarea的滚动条高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆