<!doctype html>
<html>
<head>
<title>开始使用layer</title>
</head>
<body>
<button id="test1">小小提示层</button>
你必须先引入jQuery1.8或以上版本
<script src="jQuery的路径"></script>
<script src="layer.js的路径"></script>
<script>
$('#test1').on('click', function(){
layer.msg('Hello layer');
});
</script>
当然,你也可以写在外部的js文件
</body>
</html>
<!doctype html>
<html>
<head>
<title>开始使用layer</title>
</head>
<body>
你必须先引入jQuery1.8或以上版本
<script src="jQuery的路径"></script>
<script src="layer.js的路径"></script>
<script>
//弹出一个页面层
$('#test2').on('click', function(){
layer.open({
type: 1,
area: ['600px', '360px'],
shadeClose: true, //点击遮罩关闭
content: '\<\div style="padding:20px;">自定义内容\<\/div>'
});
});
运行上述例子
//弹出一个iframe层
$('#parentIframe').on('click', function(){
layer.open({
type: 2,
title: 'iframe父子操作',
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area : ['800px' , '520px'],
content: 'test/iframe.html'
});
});
运行上述例子
//弹出一个loading层
$('#test4').on('click', function(){
var ii = layer.load();
//此处用setTimeout演示ajax的回调
setTimeout(function(){
layer.close(ii);
}, 1000);
});
运行上述例子
//弹出一个tips层
$('#test5').on('click', function(){
layer.tips('Hello tips!', '#test5');
});
运行上述例子
</script>
当你对此建立了一定的初始,你应该去详看API手册了。
</body>
</html>