function getMaxZIndex() {
const allElement = Array.from(document.all);
const zIndexArray = []
allElement.forEach((item) => {
const itemZIndex = Number(window.getComputedStyle(item, null).getPropertyValue("z-index"))
if(itemZIndex) {
zIndexArray.push(itemZIndex)
}
})
let maxZIndex = 0
if(zIndexArray.length) {
maxZIndex = Math.max(...zIndexArray)
}
return maxZIndex + 1
}
查找当前页面最大z-index
于 2023-10-28 18:33:55 首次发布