document.getElementById(“test”).style.display=“hidden” not working

后端 未结 11 1006
没有蜡笔的小新
没有蜡笔的小新 2021-02-02 14:10

I want to hide my form when I click on the submit button. My code is as follows:



        
11条回答
  •  故里飘歌
    2021-02-02 14:55

    There are two ways of doing this.

    Most of the answers have correctly pointed out that style.display has no value called "hidden". It should be none.

    If you want to use "hidden" the syntax should be as follows.

    object.style.visibility="hidden"
    

    The difference between the two is the visibility="hidden" property will only hide the contents of you element but retain it position on the page. Whereas the display ="none" will hide your complete element and the rest of the elements on the page will fill that void created by it.

    Check this illustration

提交回复
热议问题