使用jQuery自动扩展文本区域 [英] Auto expand a textarea using jQuery

查看:90
本文介绍了使用jQuery自动扩展文本区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jQuery自动扩展文本区域?

How can I make a textarea automatically expand using jQuery?

我有一个用于解释会议议程的文本框,因此当我的议程文本持续扩大该文本框区域时,我想扩展该文本框.

I have a textbox for explaining the agenda of the meeting, so I want to expand that textbox when my agenda's text keep growing that textbox area.

推荐答案

我尝试了很多, 这很棒. 链接死了较新的版本是在此处可用.参见下面的旧版本.
您可以通过在文本区域中按住Enter键来尝试.将效果与其他自动扩展的textarea插件进行比较....

I have tried lots and this one is great. Link is dead. Newer version is available here. See below for old version.
You can try by pressing and hold enter key in textarea. Compare the effect with the other auto expanding textarea plugin....

编辑基于评论

$(function() {
   $('#txtMeetingAgenda').autogrow();
});

注意:您应该包括所需的js文件...

note: you should include the needed js files...

为防止文本区域中的滚动条在&上闪烁在展开/收缩期间关闭,您也可以将overflow设置为hidden:

To prevent the scrollbar in the textarea from flashing on & off during expansion/contraction, you can set the overflow to hidden as well:

$('#textMeetingAgenda').css('overflow', 'hidden').autogrow()





更新:

上面的链接已断开.但是您仍然可以在此处获得javascript文件.

The link above is broken. But you can still get the javascript files here.

这篇关于使用jQuery自动扩展文本区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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