Animations
API
Arrays
Async
Basics
Challenges
Classes
Console
Dates
Debugging
DOM Elements
DOM Methods
DOM Properties
Event Listeners
Flow Control
Forms
Functions
Global Functions
JSON
Keywords
Libraries (3rd party)
Math
Modules
Objects
Snippets
String
Types
Widgets
Window Object
change
is easy and is often used in form controls.
// In HTML:
<element onchange="myScript"></element>
// In JavaScript:
object.onchange = function(){myScript};
// In JavaScript, using the addEventListener() method:
object.addEventListener("change", myScript);
function ShowColor()
{
let colorList = document.getElementById("ColorList");
let color = colorList.options[colorList.selectedIndex].text; //.value would get you the value and not the text
let demo1 = document.getElementById("demo1");
demo1.innerHTML = color;
}