ruby-on-rails - Jpicker rails:如何在rails中选择透明选项?
问题描述
我正在使用 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
}
解决方案
推荐阅读
- jquery - 给脚本选择器 id 与克隆的 div 相同
- android - Firebase 版本更新问题
- c++ - 为什么 Cosos2d ClippingNode 不能正常工作?
- java - 如何在android中以5秒的时间间隔依次运行X方法5次?
- vue.js - 在模态自动对焦上引导 vue 输入
- java - 如何使用java关闭/重新启动另一台Windows PC?
- c# - 我不明白为什么 PdfReader.ComputeUserPassword() 返回 null
- database - 多个表的两个 where 子句抛出 ORA-01722:无效数字
- kubernetes - Apache Airflow 或 Argoproj 用于 kubernetes 上的长时间运行和 DAG 任务
- elasticsearch - ELK - 如何在特定索引上向单个用户提供权限