How to make a DIV visible and invisible with JavaScript

后端 未结 7 512
长情又很酷
长情又很酷 2020-12-02 11:50

Can you do something like

function showDiv()
{
    [DIV].visible = true;
    //or something
}
7条回答
  •  天命终不由人
    2020-12-02 12:31

    You can use the DOM functions: setAttribute and removeAttribute. In the following link you have an example of how to use them.

    setAttribute and removeAttribute functions

    A quick view:

    hide:    document.getElementById("myDiv").setAttribute("hidden","");
    unhide:  document.getElementById("myDiv").removeAttribute("hidden");
    

提交回复
热议问题