我正在使用 Jpicker 选择背景颜色,并且没有选择透明的选项。我想添加一个函数,如果输入为空白,则将颜色设置为透明。我尝试将以下内容添加到初始化代码中,但它对我不起作用。
function (color, context) {
var all = color.val('all');
alert('Color chosen - hex: ' + (all && '#' + all.hex || 'none') + ' - alpha: ' + (all && all.a + '%' || 'none'));
if (all.a != null)
{
var b = Math.precision((all.a * 100) / 255, 0);
alert(b);
}
$('#Commit').css(
{
backgroundColor:all && '#' + all.hex || 'transparent'
}); // prevent IE from throwing exception if hex is empty
}