简体   繁体   中英

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 ?

I want the textchange event to occur once 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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM