【发布时间】:2012-05-03 14:59:32
【问题描述】:
我正在使用这个颜色选择器http://www.eyecon.ro/colorpicker 并尝试捕获十六进制值,以便我可以在服务器端使用它来存储所选颜色。
更改默认颜色后无法获取所选颜色。
这是我的代码:
var currentHex = '#0000ff';
alert(currentHex);
$('#colorSelector').ColorPicker({
color: currentHex,
onShow: function (colpkr) {
$(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
$(colpkr).fadeOut(500);
return false;
},
onChange: function (hsb, hex, rgb) {
// every time a new colour is selected, this function is called
currentHex = hex;
$('#mycolor').val = currentHex;
}
});
HTML:
<div id="colorSelector"><div style="background-color: rgb(62, 62, 189); "></div></div>
<input type="text" maxlength="6" size="6" id="mycolor" value="00ff00">
这是我的Demo
【问题讨论】:
标签: jquery hex color-picker