HTML onchange attribute event occurs if the browsers feel that the audio/video having to stop for buffering. It is similar to the oninput event attribute. But the difference is while oninput attribute event occurs immediately after the value of element changes, while an onchange event occurs when the element loses focus.
HTML onchange attribute
The HTML onchange attribute is also part of the event attribute. And it is part of the elements like <audio> and <video>.
Syntax: <element onchange=”script” >
Browser compatibility
This attribute supports different types of browsers as follows
- Chrome
- Mozilla
- InternetExplorer
- Safari
- Opera
Example:
<!DOCTYPE html> <html> <head> <title>Freshersnow onchange attribute</title> </head> <body> Select Freshersnow Tutorial :<br><br> <select name="tutorial" onchange="onChange(this.value)"> <option value="HTML">Freshersnow HTML</option> <option value="CSS">Freshersnow CSS</option> <option value="PHP">Freshersnow PHP</option> </select> <script> function onChange(val) { alert("The Value Changed as : " + val); } </script> </body> </html>
Output: