How to make a DIV visible and invisible with JavaScript

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

Can you do something like

function showDiv()
{
    [DIV].visible = true;
    //or something
}
7条回答
  •  春和景丽
    2020-12-02 12:10

    You can use opacity which is similar to visibility but allow to smooth transition and control other parameters like height (for snippet simplicity I put js logic in html directly - don't do it in production code)

    .box { width:150px; height: 150px; background: red; transition: 0.5s }
    
    .hide { opacity: 0; height: 10px}

提交回复
热议问题