Question

I searched for a jquery color picker plugin and found the Colpick plugin from this link.

When I tried to implement it, I have no idea why it doesn't work.

I've tried implementing it on this jsfiddle, but still it doesn't work.

Am I missing something or there's something wrong in how I implement it, that's why it doesn't work?

$('#picker').colpick({
    layout:'hex',
    submit:0,
    colorScheme:'dark',
    onChange:function(hsb,hex,rgb,el,bySetColor) {
        $(el).css('border-color','#'+hex);
        // Fill the text box just if the color was set using the picker, and not the colpickSetColor function.
        if(!bySetColor) $(el).val(hex);
    }
    }).keyup(function(){
        $(this).colpickSetColor(this.value);


    });
Était-ce utile?

La solution

according to your project on jsfiddle you called plugin before it defined.i correct your code and it works fine. see jsfiddle
i just moved your code:

$('#picker').colpick({
    layout:'hex',
    submit:0,
    colorScheme:'dark',
    onChange:function(hsb,hex,rgb,el,bySetColor) {
    $(el).css('border-color','#'+hex);
    // Fill the text box just if the color was set using the picker, and not the colpickSetColor function.
    if(!bySetColor) $(el).val(hex);
}
}).keyup(function(){
    $(this).colpickSetColor(this.value);
});

at the end of java scripts

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top