Javascript change vs input event

·

1 min read

This will just be a quick blog.

I’ve been re-learning the fundamentals of web development. It includes reviewing and going through the basics of javascript which is usually neglected as we heavily use high level frameworks such as React.

One interesting find is that there are two seemingly similar event types that fires upon updating an input element.

<input input=“”>
<input change=“”>

It would be really useful to know the difference between the two. Both fires whenever there is an update from the input element. Their main difference is the timing of when they are firing.

The input event fires whenever the input element is updated. i.e. there is a text change for text type input element.

Meanwhile, the change event (generally) fires whenever the the input element loses focus. i.e. when a user finished editing an text type input element.

Check the docs for more information: Change event