Home >Web Front-end >Layui Tutorial >Layui method to close the current pop-up box

Layui method to close the current pop-up box

王林
王林forward
2021-03-03 11:05:305221browse

Layui method to close the current pop-up box

This article shares two situations and methods for closing the current pop-up box in layui. I hope it can help everyone.

layer.close(index) - Close a specific layer

//当你想关闭当前页的某个层时

var index = layer.open();
var index = layer.alert();
var index = layer.load();
var index = layer.tips();

//正如你看到的,每一种弹层调用方式,都会返回一个index
layer.close(index); //此时你只需要把获得的index,轻轻地赋予layer.close即可

//如果你想关闭最新弹出的层,直接获取layer.index即可
layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的

//当你在iframe页面关闭自身时
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index); //再执行关闭

layer.closeAll(type) - Close all layers

The closeAll() method will destroy all the current page layer layer, or closeAll(type) only closes a certain type of layer

layer.closeAll();   //关闭所有层

layer.closeAll('dialog');   //关闭信息框

layer.closeAll('page');   //关闭所有页面层

layer.closeAll('iframe');   //关闭所有的iframe层

layer.closeAll('loading');   //关闭加载层

layer.closeAll('tips');   //关闭所有的tips层

Related recommendations: layui tutorial

The above is the detailed content of Layui method to close the current pop-up box. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete