JS DOM: input color picker 🌈

By Xah Lee. Date: . Last updated: .

Color Picker Example

Value is:

Code

<label for="colorpick_YS5kR">Color:</label>
<input id="colorpick_YS5kR" type="color" value="#ff0000" />

Value is:
<span id="output_ghcpH"></span>
"use strict";
{
    const colorpick_YS5kR = document.getElementById("colorpick_YS5kR");
    const output_ghcpH = document.getElementById("output_ghcpH");
    const f_update = () => {
        output_ghcpH.textContent = colorpick_YS5kR.value;
    };
    colorpick_YS5kR.addEventListener("input", f_update);
    f_update();
}