The onchange event is not working in color type input with JavaScript

The onchange event triggers when an element changes. You need to use below syntax.

onchange="yourFunctionName(this);"

Example





Document





To run the above program, save the file name anyName.html(index.html) and right click on the file and select the option open with live server in VS code editor.

Output

After clicking the input type color, you will get the color value in console ?

Updated on: 2026-03-11T22:50:50+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements