Geo*_*rge 2 javascript jquery color-picker
我正在使用这个 jQuery Colorpicker http://www.eyecon.ro/colorpicker/#about
有什么办法可以让它在从颜色选择器中单击时更改输入的值(*颜色代码)?
现在它只通过单击颜色选择器上的提交按钮来提交选择的颜色。
<input type="text" value="#FFFFFF">
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function ($) {
$('input').ColorPicker({
onSubmit: function(hsb, hex, rgb, el) {
$(el).val('#' + hex);
$(el).ColorPickerHide();
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
}
})
.bind('keyup', function(){
$(this).ColorPickerSetColor(this.value);
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
找不到好的方法,但这里有一个丑陋但希望不是完全糟糕的方法:
jQuery(document).ready(function ($) {
var $pickerInput;
$('input').ColorPicker({
onSubmit: function(hsb, hex, rgb, el) {
$(el).val('#' + hex);
$(el).ColorPickerHide();
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
$pickerInput = $(this);
},
onHide: function(picker) {
$pickerInput.val('#' + $(picker).find('.colorpicker_hex input').val());
}
})
.bind('keyup', function(){
$(this).ColorPickerSetColor(this.value);
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2053 次 |
| 最近记录: |