jPicker プラグインを使用して、ピッカーから色を取得しています。この方法で要素を作成します。
$(function(){
$('#txtBackgroundColor').jPicker(
{
color:
{
mode: 'h', // acceptable values "h" (hue), "s" (saturation), "v" (brightness), "r" (red), "g" (green), "b" (blue), "a" (alpha)
active: new $.jPicker.Color({ hex: 'eaeaea' }), // accepts any declared jPicker.Color object or hex string WITH OR WITHOUT '#'
},
window:
{
position:
{
x: 'screenCenter', // acceptable values "left", "center", "right", "screenCenter", or relative px value
y: '200px', // acceptable values "top", "bottom", "center", or relative px value
},
expandable: true
},
},
});
ボタンをクリックすると、その jpicker のアクティブな色を設定したいと思います。ドキュメントでこの行を見ました:
$('#update').click(function(){
$.jPicker.List[0].color.active.val('hex', 'e2ddcf', this);
});
しかし問題は、複数の jPicker があり、リストのインデックスがわからないことです。たとえば、リストのインデックスではなく ID で jPicker の色を設定する方法はありますか?
ありがとう