[英]javascript/jquery trigger a text change event on a textarea
Is there anyway to trigger the textChanged event in a text area using javascript or jquery ?无论如何,是否可以使用 javascript 或 jquery 在文本区域中触发 textChanged 事件?
I want the textchange event to occur once the page is loaded.我希望在加载页面后发生 textchange 事件。
$(document).ready(function() {
$('textarea').trigger('change');
});
But this will only trigger if the change event was added through jQuery.但这只会在通过 jQuery 添加更改事件时触发。 If not you could try:
如果没有,您可以尝试:
$('textarea').get(0).change();
Have you tried:你有没有尝试过:
$(function(){
$("textarea").change()
})
In my case, I have to use the event input
since my textarea used as emoji field.就我而言,我必须使用事件
input
因为我的 textarea 用作表情符号字段。
For ex.例如。
$('textarea').trigger('input');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.