admin管理员组文章数量:1394601
Is it possible to get width of text inside a textarea element?
I don't want $('textarea').val().length
per se, as it doesn't depend on font-size.
I would prefer the absolute width of the text inside.
Is it possible to get width of text inside a textarea element?
I don't want $('textarea').val().length
per se, as it doesn't depend on font-size.
I would prefer the absolute width of the text inside.
Share Improve this question edited Sep 21, 2018 at 2:53 Jesse W. Collins 1391 gold badge1 silver badge12 bronze badges asked Oct 17, 2010 at 12:29 framomo86framomo86 1,2052 gold badges14 silver badges17 bronze badges1 Answer
Reset to default 9It's well possible this information is impossible to get hold of.
Workaround idea:
- Create a
span
element with the font size settings of the textarea - Give the span element the input's value using
.text(value)
- Measure the span's width
本文标签: How to get text width inside textarea (javascriptjquery)Stack Overflow
版权声明:本文标题:How to get text width inside textarea? (javascriptjquery) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744095109a2590141.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论