直接用cdn写个实例
<html><head>
<meta http-equiv="Content-Type" content="text/html charset=utf-8"/>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.1.2/jquery.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/layer/3.0.3/layer.min.js"></script>
</head>
<style>
.link {
color: #0a8ddf
cursor: pointer
}
</style>
<script>
layer.open({
title: '测试',
content: '<a class="link">点击关闭跳转</a>',
success: function (layero, index) {
$(layero).find('.link').click(function () {
layer.close(index)
window.location.href = 'http://www.baidu.com/'
})
}
})
</script>
</html>
网友看看是否符合需求,修改起来也很方便,都做了注释;实在不会的,去查看手册即可
<!DOCTYPE HTML>
<html>
<meta charset="UTF-8" />
<head>
<title></title>
</head>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/layer/3.0.1/layer.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function() {
$('.btn').click(function() {
layer.msg('加载中(点击关闭)', {
anim: 4, //动画效果
icon: 16,
shade: 0.5, //遮罩层透明度
shadeClose: true, //点击遮罩层关闭
time: 0, //不自动关闭
}, function() {
layer.alert('显示加载信息后,你可以执行别的操作,就像这样', {
skin: 'layui-layer-lan',
closeBtn: 0,
anim: 6 //动画类型
})
})
})
})
</script>
<style type="text/css">
html,
body {
margin: 0
padding: 0
}
.demo {}
</style>
<body>
<div class="demo">
<button class="btn">点击显示效果</button>
</div>
</body>
</html>