我做的一个弹窗小插件,用的layer库,主要代码如下:layer.ready(function() {
layer.open({
type: 0,
title: '标题',
content: $('#popup_content').html(),
skin: '',
area: ['500px', '200px'],
btn: ['ok', 'no'],
yes: function (index, layero) {
var val = layero.find('#noremind').is(':checked');
layer.close(index);
if(val) {
//
}
},
btn2: function(index) {
layer.close(index);
}
});
});
html部分是:
<div id = "popup_content" style = "display: none;">
弹窗内容
<div style = "text-align: right;">
<input style = "vertical-align: middle;" type = "checkbox" name = "noremind" value = "1" id="noremind" /><label for="noremind">不再提醒</label>
</div>
</div>
如果你想获取popup_content元素里的表单值,可以通过按钮函数的第二个参数,layero,如代码所示,然后用这个查找表单。pc是这么搞的,但是手机端不行,下面直接上手机端代码:
layer.open({
type: 0,
title: '{$this->config['title']}',
content: $('#popup_content').html(),
btn: ['{$this->config['btntext2']}', '{$this->config['btntext']}'],
success: function(e) {
dom = e;
},
no: function (index) {
var val = $(dom).find('#noremind').is(':checked');
layer.close(index);
if(val) {
setcookie('nciaer_popup', "1", 86400 * 365);
}
},
yes: function(index) {
layer.close(index);
location.href = '{$this->config['url2']}';
},
});
html部分是:
<div id = "popup_content" style = "display: none;">
弹窗内容
<div style = "text-align: right;">
<input style = "vertical-align: middle;" type = "checkbox" name = "noremind" value = "1" id="noremind" /><label for="noremind">不再提醒</label>
</div>
</div>
手机端按钮方法没有第二个参数,但是有个success方法,这个方法是弹窗成功弹出后调用,并且传入一个当前弹窗元素e,我定义一个全局变量dom来接收它,然后在按钮事件函数里通过dom变量来查找表单元素。
有关PHP系统、Discuz或网站等各种问题,可以联系QQ1069971363寻求付费支持
|