我使用這個顏色拾取http://www.eyecon.ro/colorpicker,我試圖捕捉到的十六進制值,這樣我可以用它在服務器端存儲所選擇的顏色。JQuery的顏色選擇器改變十六進制值
我無法更改默認的顏色之後獲得所選擇的顏色。
這裏是我的代碼:
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
@ ocanal,謝謝您的快速reply.This是我所需要的東西:) – coder 2012-04-22 23:40:05
@coder,:)很樂意幫助你 – ocanal 2012-04-22 23:41:24