javascript/jquery 在 textarea 上触发文本更改事件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5965919/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
javascript/jquery trigger a text change event on a textarea
提问by Aneef
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 事件。
回答by Gary Green
$(document).ready(function() {
$('textarea').trigger('change');
});
But this will only trigger if the change event was added through jQuery. If not you could try:
但这只会在通过 jQuery 添加更改事件时触发。如果没有,您可以尝试:
$('textarea').get(0).change();
回答by Grooveek
Have you tried:
你有没有尝试过:
$(function(){
$("textarea").change()
})