I use this colorpicker http://www.eyecon.ro/colorpicker and try to capture the hex value so that I can use it on the server side to keep the selected color.
I cannot get the selected color after changing the default color.
Here is my code:
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) {
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">
Here is my demo
coder source
share