How can I change the value in the input?

  • 0
    Hello, there is a code:
      <input type="color" value="" id="favcolor">
    <input id="hex">
        var theInput = document.getElementById("favcolor");
        var theColor = theInput.value;
        theInput.addEventListener("input", function() {
        document.getElementById("hex").innerHTML = theInput.value;

    After choosing a color, the color code is added in the console (ctrl + shift + c in chrome), but in fact this is not visible, please tell me
    JavaScript Anonymous, Dec 4, 2019

  • 1 Answers
  • 0
    not innerHTML

    document.getElementById("hex").innerHTML = theInput.value;

    a value

    document.getElementById("hex").value = theInput.value;

    since there input

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!