gpt4 book ai didi

javascript - 文本区域自动增长 onkeyup

转载 作者:行者123 更新时间:2023-11-28 08:44:53 25 4
gpt4 key购买 nike

我正在使用这个脚本

 jQuery.each(jQuery('textarea[data-autoresize]'), function() {
var offset = this.offsetHeight - this.clientHeight;

var resizeTextarea = function(el) {
jQuery(el).css('height', 'auto').css('height', el.scrollHeight + offset);
};

jQuery(this).on('keyup input', function() {
resizeTextarea(this); }).removeAttr('data-autoresize');
});
});

这是我的html

<h:inputTextarea id="newUserIds" value="#{surveyAction.newUsers}"
cols="41" rows="10" onkeyup="AutoGrowTextArea(this)"
styleClass="animated">
<p:ajax event="blur" process="@this" immediate="true" />
</h:inputTextarea>

我如何定位 javascript 上的特定文本区域,以便该操作仅适用于那里。

最佳答案

您当前的选择器找不到您的文本区域元素。

将 jQuery 选择器从 textarea[data-autoresize] 更改为 #newUserIds,或者更改您的 textarea 标签并添加属性 data-autoresize(推荐):

<h:inputTextarea id="newUserIds" value="#{surveyAction.newUsers}" cols="41" rows="10" onkeyup="AutoGrowTextArea(this)" styleClass="animated">

关于javascript - 文本区域自动增长 onkeyup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27633390/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com