This article mainly introduces the sample code for using js to close the window of the js pop-up layer. Friends who need it can come and refer to it. I hope it will be helpful to everyone
Two methods: remove and hide
//创建你的弹出层 var dvMsg = document.createElement("p"); strHtml = "弹出层内容
" strHtml += " " dvMsg.innerHTML = strHtml; document.body.appendChild(dvMsg); // 关闭按钮 btnclick = function (){ document.body.removeChild(dvMsg);
-------------------------
Or the pop-up layer is marked with p id
弹出层内容
js
function open(){ document.getElementById(tanchu).style.display=""; //显示 } function close(){ document.getElementById(tanchu).style.display="none"; //不显示(页面初始化的时候同样加载一遍) }
The above is the detailed content of js implements the window function code for closing the js pop-up layer. For more information, please follow other related articles on the PHP Chinese website!