1、HTLM部分,先创建弹出层且隐藏和按钮。
<div id="cover" style="position: fixed; top: 0px; width: 100%; height: 100%; z-index: 99999999; display: none; background: rgba(0, 0, 0, 0.8);"><img src="图片URL" style="width:50%;margin-left: 25%;margin-top: 25%;"></div> <a href="javascript:;" id="btn-qrcode">点击这里</a>
2、当用户点击按钮时,利用JS进行展示或隐藏图层。
<script type="text/javascript"> $('#btn-qrcode').click(function(){ $('#cover').fadeIn(200).unbind('click').click(function(){ $(this).fadeOut(100); }) }); </script>
转载请注明: haoshu发表于浩叔逛逛>>https://www.haoshu888.com/js/1153.html