Show/Hide div, with plain JS

后端 未结 6 584
独厮守ぢ
独厮守ぢ 2021-01-19 23:23

My CSS:

#a_x200{
    visibility: hidden;
    width: 200px;
    height: 200px;
    background-color: black;
}

My JS:



        
6条回答
  •  南笙
    南笙 (楼主)
    2021-01-19 23:56

    You're using visibility: hidden to hide it, then attempting to use the display CSS property to make it visible. They're two completely separate properties, changing one won't magically change the other.

    If you want to make it visible again, change the value of the visibility property to visible:

    document.getElementById('a_x200').style.visibility = 'visible';
    

提交回复
热议问题