Open In App
Related Articles

HTML onchange Event Attribute

Improve Article
Save Article
Like Article

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 event attribute. It is similar to oninput event attribute. But the difference is while oninput attribute event occurs immediately after the value of element changes, while onchange event occur when the element looses focus. This attribute is associated with <select> element.

Supported Tags:

  • <input type=”checkbox”>
  •  <input type=”file”>
  •  <input type=”password”>
  •  <input type=”radio”>
  •  <input type=”range”>
  •  <input type=”search”>
  •  <input type=”text”>
  •  <select> 
  •  <textarea>


<element onchange = "script">

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



<!DOCTYPE html>
    <title>onchange event attribute</title>
        body {
        h1 {
    <h2>onchange Event Attribute</h2>
    <p>Choose Subject:</p>
    <select id="GFG"
        <option value="Data Structure">Data Structure
        <option value="Algorithm">Algorithm
        <option value="Computer Network">Computer Network
        <option value="Operating System">Operating System
        <option value="HTML">HTML
    <p id="sudo"></p>
        function Geeks() {
            let x = document.getElementById("GFG").value;
            document.getElementById("sudo").innerHTML =
            "Selected Subject: " + x;


Supported Browsers: The browser supported by onchange event attribute are listed below: 

  • Apple Safari 3
  • Google Chrome 1
  • Edge 12
  • Firefox 1
  • Opera 9

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 04 Aug, 2023
Like Article
Save Article
Similar Reads
Complete Tutorials