封装弹出层调用函数
/*弹出层*/ function getDiv(title, id, w, h) { if (title == null || title == '') { title = false; } if (w == null || w == '') { w = ($(window).width() * 0.9); } if (h == null || h == '') { h = ($(window).height() - 50); } layer.open({ type: 1, area: [w + 'px', h + 'px'], title: false, //title: title, fix: false, //不固定 maxmin: false, shadeClose: true, closeBtn: 2,//关闭按钮,0不显示,1和2两种风格; anim: 3,//弹出动画,0~6; shade: 0.6,//遮罩层 skin: 'layui-layer-nobg layer_bg', //没有背景色 content: $(id), }); }
HTML页面调用
<div class="ctitle">年龄占比分析 <span class="laybg new2" onClick="getDiv('年龄占比分析','#popup2',750,550)"><i class="icon2"> </i></span> <div id="ages"></div> </div>
HTML页面要显示的层
<!--弹窗内容 Begin--> <!--年龄--> <div class="popup" id="popup2"> <div id="ages2" style="width:750px;height:550px;"></div> </div> <!--弹窗信息 End-->
Done !