开发者

javascript/jquery trigger a text change event on a textarea

开发者 https://www.devze.com 2023-03-05 16:09 出处:网络
Is there anyway to trigger the textChanged event in a text area using javascript or jquery ? I want the textchange event to occur once 开发者_StackOverflow中文版the page is loaded.$(document).ready(f

Is there anyway to trigger the textChanged event in a text area using javascript or jquery ?

I want the textchange event to occur once 开发者_StackOverflow中文版the page is loaded.


$(document).ready(function() {
   $('textarea').trigger('change');
});

But this will only trigger if the change event was added through 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.

For ex.

$('textarea').trigger('input');
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号