//父层级设置显示样式
document.getElementById("maskDiv").style.display = 'block';
//子节点设置样式var mask = document.createElement('div');
mask.id = 'maskDiv';
mask.style.width = window.innerWidth +'px';
mask.style.height = window.innerHeight +'px';
mask.style.background = '#000000';
mask.style.opacity = '0.1';
mask.style.position = 'absolute';
mask.style.display = 'block'; // 取消遮罩 设置为 none
mask.style.top = 30+'px';
mask.style.zIndex = 999; // 设置元素层级
document.body.appendChild(mask);
// 原文链接:https://blog.csdn.net/shihongji/article/details/81118937