How to hide a div with jQuery?

前端 未结 7 2034
说谎
说谎 2020-11-30 02:04

When I want to hide a HTML

, I use the following JavaScript code:

var div = document.getElementById(\'myDiv\');
div.style.visibility          


        
相关标签:
7条回答
  • 2020-11-30 02:58

    If you want the element to keep its space then you need to use,

    $('#myDiv').css('visibility','hidden')
    

    If you dont want the element to retain its space, then you can use,

    $('#myDiv').css('display','none')
    

    or simply,

    $('#myDiv').hide();
    
    0 讨论(0)
提交回复
热议问题