A weird thing with textarea input event?

As textarea is not an input there is allowed input event?


var button = $("#buttonId");
  if(e.target.value === ''){
    // Textarea has no value
  } else {
    // Textarea has a value

This normal?


I think you might be looking for .on('keyup') or .on('keypress').

Are you asking why it works? Or are you saying it isn’t working for you? The input event should work.

1 Like

Why is work? But thanks!

It works because it is a valid event on the HTMLTextAreaElement interface, just as it is for <input> and <select> elements.

1 Like

What you said is very interesting.

Can you take a look here?


So this case on select element is work like a change event? So if use change event there is will do same? This case what the advantage to use input or change?


For the select element there isn’t really much difference. But for text input elements the difference is in when the event is fired.

input event

Note: The input event is fired every time the value of the element changes. This is unlike the change event, which only fires when the value is committed, such as by pressing the enter key, selecting a value from a list of options, and the like.

1 Like