我想使用 jpicker 修改多个元素,这是单个元素的代码(#body02),是否可以为每个元素创建一个数组?
$(document).ready(
function()
{
var LiveCallbackElement = $('#body02'),
LiveCallbackButton = $('#LiveButton'); // you don't want it searching this
// on every live callback!!!
$('#Callbacks').jPicker(
{window:{position:{x:'screenCenter',y:'200'}}},
function(color, context)
{
var all = color.val('all');
alert('Color chosen - hex: ' + (all && '#' + all.hex || 'none') +
' - alpha: ' + (all && all.a + '%' || 'none'));
$('#body02').css(
{
backgroundColor: all && '#' + all.hex || 'transparent'
}); // prevent IE from throwing exception if hex is empty
},
function(color, context)
{
if (context == LiveCallbackButton.get(0)) alert('Color set from button');
var hex = color.val('hex');
LiveCallbackElement.css(
{
backgroundColor: hex && '#' + hex || 'transparent'
}); // prevent IE from throwing exception if hex is empty
},
function(color, context)
{
alert('"Cancel" Button Clicked');
});
$('#LiveButton').click(
function()
{
$.jPicker.List[0].color.active.val('hex', 'e2ddcf', this);
});
});
谢谢