How can I change the value in the input?

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

    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
    Anonymous

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