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

后端 未结 11 968
没有蜡笔的小新
没有蜡笔的小新 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:53

    Using jQuery:

       $('#test').hide();
    

    Using Javascript:

    document.getElementById("test").style.display="none";
    

    Threw an error "Cannot set property 'display' of undefined"

    So, fix for this would be:

    document.getElementById("test").style="display:none";
    

    where your html code will look like this:

提交回复
热议问题