colpick是一款轻量级、可自由定制的jQuery颜色选择器插件。colpick颜色选择器可以拾取RGB、HEX、HSB等格式的颜色。
使用方法:
首先要引入必要的文件:
1
2
|
<
script
src
=
"js/colpick.js"
type
=
"text/javascript"
></
script
>
<
link
rel
=
"stylesheet"
href
=
"css/colpick.css"
type
=
"text/css"
/>
|
html结构:
1
|
<
button
id
=
"picker"
>Show Color Picker</
button
>
|
调用颜色选择器插件。
1
|
$(
'#picker'
).colpick();
|
可选参数:
demo:
$(".u-color b").colpick({
layout: 'hex',
submit: 0,
onChange: function (hsb, hex, rgb, el, bySetColor) {
changeObj = true;
var color_text = '#' + hex;
$(el).css('background', color_text);
$(el).attr("data-color", color_text);
}
});