web彈層組件layer

<!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>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章