test addEventListener

by mccarthysean

HTML

<html>
  <div id="myDiv">
  </div>
</html>

JavaScript

/* First add an input color selector as a child of #myDiv with a datalist of available colors */
document.querySelector("#myDiv").innerHTML += `
  <input id="myInput" type="color" list="presetColors" colorpick-eyedropper-active="false">
  <datalist id="presetColors">
    <option>#0275d8</option>
    <option>#5cb85c</option>
  </datalist>
`;

/* Trying to console.log the color value that was chosen in the input */
function myFunction(event) {
  console.log(event.value);
}

/* Adding an event listener so tha */
document
  .querySelector("#myInput")
  .addEventListener("change", myFunction(e));