Home  >  Article  >  Web Front-end  >  js implements the window function code for closing the js pop-up layer

js implements the window function code for closing the js pop-up layer

怪我咯
怪我咯Original
2017-07-04 15:24:561962browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn