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',
精彩评论