开发者

jQuery Colour Picker - Dynamic Selector

Hey Guys, basically what im trying to do is use the one instance for all the colour selectors on my page. The code im using is this.

$('.color').ColorPicker({ 
        color: '#0000ff',
    onShow: function (colpkr) { $(colpkr).fadeIn(500); return false; },
    onHide: function (colpkr) { $(colpkr).fadeOut(500)开发者_Go百科; return false; },
    onChange: function () { $(this).css('backgroundColor', '#' + hex);}
});

The problem is though, the onChange function doesnt select $(this) as the selector clicked, but changes the colour of the colour picker ui itself.

How do I reference the actual value while still keeping it dynamic to any color selector on the page?

The plugin im using is http://www.eyecon.ro/colorpicker/

Thanks, Warren


  • DEMO: http://so.devilmaycode.it/jquery-colour-picker-dynamic-selector
$(function() {
  $('.color').ColorPicker({
  color: '#0000ff',
  onShow: function (colpkr) { $(colpkr).fadeIn(500); return false; },
  onHide: function (colpkr) { $(colpkr).fadeOut(500); return false; },
  onSubmit: function(hsb, hex, rgb, el) {
    $(el).val(hex);
    $(el).ColorPickerHide();
    $(el).css('backgroundColor', '#' +hex);
  }});  
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜