在layer.open中,默认左边的按钮的是蓝色的。右边的按钮是没有背景色的。 有的情况是需要调换这个背景色的。 下面是实现方法: btn1对应的是'确认' ->对应.layui-layer-btn0 , btn2对应的是'取消' ->对应.layui-layer-btn1 在 success 回调中动态修改按钮样式(推荐):代码如下 layer.open({ type: 1, title: "提示", content: '' + '按钮背景色的调换', area: ['350px', '150px'], btn: ["确认", "取消"], btn1: function(index1, layero, that){ layer.close(index1); }, btn2: function(index1, layero, that){ layer.close(index1); }, success: function(layero) { layero.find('.layui-layer-btn0').css({ backgroundColor: 'transparent', border: '1px solid #ccc', color: '#333' }); layero.find('.layui-layer-btn1').css({ backgroundColor: '#1E9FFF', border: '1px solid #1E9FFF', color: '#fff' }); } }); 添加了 success: function(layero) 的代码后, 现在 确认按钮是没有背景色的,取消按钮的背景色是蓝色。
评论 (0)
请 登录 后发表评论