1. 程式人生 > >layer.alert回撥函式執行關閉彈窗

layer.alert回撥函式執行關閉彈窗

對於layer.alert()彈出層來說,想要在回撥函式中執行一些操作。 此時點選確定會執行回撥函式,但並不會自動關閉彈窗。 layer.alert彈窗

layer.alert('完成測評', { icon: 1, closeBtn: 0 }, function (index) { 
	$(".container").addClass("hidden");
	$(".page3").removeClass("hidden");
});

此時就需要在回撥函式中手動關閉彈窗

layer.alert('完成測評', { icon: 1, closeBtn: 0 }, function (index) {
    //關閉彈窗
    layer.close(index);		 	 // 關閉所有彈窗     layer.closeAll();    parent.layer.closeAll();
    setTimeout(function () { 
    	$(".container").addClass("hidden");
    	$(".page3").removeClass("hidden");
    }, 500)
 });
layer.alert('完成測評', { icon: 1, closeBtn: 0 }, function () {
	var index = parent.layer.getFrameIndex(window.name);
	parent.layer.closeAll(index);
}