开发者

a problem with the jquery color picker?

开发者 https://www.devze.com 2023-01-25 07:25 出处:网络
i have this jquery colorpicker from http://www.eyecon.ro/colorpicker/ , everything is working fine 开发者_StackOverflow社区but i dnt seem to know how when the page is loaded i want the colorpicker to

i have this jquery colorpicker from http://www.eyecon.ro/colorpicker/ , everything is working fine 开发者_StackOverflow社区but i dnt seem to know how when the page is loaded i want the colorpicker to be on a default chosen color i.e black

i have a working code http://jsfiddle.net/SpmuV/5/

p.s. the default one is white, but i want to change it to black. thanks for this :))


OK, I misunderstood your question. From your example

http://jsfiddle.net/SpmuV/14/

$(document).ready(function(){


$('#colPick').css('background-color', '#000000');
$("#colPick").ColorPicker({
    color: '#000000',
    onShow: function (colpkr) {
        $(colpkr).fadeIn(500);
        return false;
    },
    onHide: function (colpkr) {
        $(colpkr).fadeOut(500);
        return false;
    },
    onChange: function (hsb, hex, rgb) {
        $('#colPick').css('background-color', '#' + hex);
    }
}); 

});

Ok, notice the OnChange event delegate, your selector is wrong, you need to change it to '#colPick'.

And since we are hard coding the default value to black for the color picker, we can do the same for our selector control with $('#colPick').css('background-color', '#000000');


Just change the color? color: '#0000ff'-> color: '#000000',

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号