Michal
Michal

Reputation: 65

ColorPick jQuery

I wanted save value in inputbox to JS variable, but when i save it, doesn't appear in console, why? thanks for advice

<!DOCTYPE html>
<html dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Color Picker</title>
    <link href="color-picker.min.css" rel="stylesheet">
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js" ></script>
  </head>
  <body>
    <p><input type="text"></p>
    <script src="color-picker.min.js"></script>
    <script>
      var picker = new CP(document.querySelector('input'));
      picker.on("change", function(color) {
        this.target.value = '#' + color;
      })

function colorpick() {


    var el = document.querySelector('input');
      console.log(el);
    }
    </script>
    <input onclick="colorpick()" type="button" class="button" value="Submit">
  </body>
</html>

Upvotes: 0

Views: 52

Answers (1)

serdar.sanri
serdar.sanri

Reputation: 2228

I am not sure what are you trying to accomplish but colorpick function is only selector of the input element itself. You need console.log(el.value) instead.

Upvotes: 1

Related Questions