我正在努力实现这个 ColorPicker 插件:
http://www.eyecon.ro/colorpicker/
我有一个包含多个字段的表单,我希望在选择任何字段时弹出颜色选择器,并根据所做的选择更改值。
这是我的代码:
jQuery(function($) {
function changeColor(e) {
e.preventDefault();
$(this).ColorPicker({
onChange: function(hsb, hex, rgb) {
$(this).attr('value', '#' + hex)
}
});
}
$('form.niceform input').live('mouseup', changeColor);
})
但是由于某种原因, $(this).attr... 部分没有识别出 $(this) 是当前选定的字段。
有人可以帮我理解我做错了什么吗?
谢谢!