1

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.

3
  • do you want to trigger it manually? Commented May 11, 2011 at 14:31
  • To help better address your issue, what do you plan to do with the text area data if a textChanged event occurs? Commented May 11, 2011 at 14:31
  • sorry guys, yes i wanted to trigger a textchanged event manually Commented May 13, 2011 at 6:30

3 Answers 3

14
$(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();
Sign up to request clarification or add additional context in comments.

1 Comment

And if it's not a textarea but contenteditable div? Then the "$('textarea').get(0).change();" brings Uncaught TypeError: textarea.get(...).change is not a function
3

Have you tried:

$(function(){
    $("textarea").change()
})

Comments

1

In my case, I have to use the event input since my textarea used as emoji field.

For ex.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.