Search code examples
javascriptjscolor

Why JSColor is not initializing on input?


I'm trying to integrate jscolor in a page but it's not working

Input:

<input type="text" id="background_color" name="background_color" class="jscolor" placeholder="Background Color" data-bind="value: background_color">

JSColor CDN Link:

<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/color-js/1.0.1/color.min.js"></script>

I'm not getting any errors in console! When I click the input field it doesn't show the color picker!

Snippet:

<script src="https://cdnjs.cloudflare.com/ajax/libs/color-js/1.0.1/color.min.js"></script>

<input type="text" id="background_color" name="background_color" class="jscolor" placeholder="Background Color" data-bind="value: background_color">

UPDATE:

The problem was in the src url I was using for js-color library. From the answer below I got the correct URL!


Solution

  • After some searching, I found a different URL that makes it work:

    src="https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.0.4/jscolor.min.js"
    

    I assume this is fine, unless you really want to specifically use that version/library, though I'm not sure if your URL is JSColor or some different library.