VOOZH about

URL: https://www.geeksforgeeks.org/html/html-onchange-event-attribute/

⇱ HTML onchange Event Attribute - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML onchange Event Attribute

Last Updated : 11 Jul, 2025

The onchange event attribute works when the value of the element changes and select the new value from the List. It is a part of the event attribute. It is similar to oninput event attribute. But the difference is that oninput attribute event occurs immediately after the value of the element changes, while onchange event occurs when the element loses focus. This attribute is associated with <select> element.

It is commonly employed in forms to validate or process data upon user interaction and enables real-time updates and validation, enhancing the user experience.

Syntax:

<element onchange = "script">

Supported Tags:

Attribute Value:

This attribute contains single value script which works when onchange attribute called.

Example:

In this example, we will see the implementation of onchange tag.

Output:

👁 sw
Output

Example:

In this example, we will see the implementation of onchange tag.

Output: In the output you can see that on checking the checkbox, onchange event is triggered and this action is added in empty array from javascript.

👁 swe
Output

Supported Browsers:

  • Google Chrome 1 and above
  • Edge 12 and above
  • Firefox 1 and above
  • Opera 9 and above
  • Safari 3 and above
Comment
Article Tags: