How to hide a div using javascript

后端 未结 6 994
感动是毒
感动是毒 2021-01-26 05:04

I want to hide a div using Javascript. Below is my div.

相关标签:
6条回答
  • 2021-01-26 05:16

    Try this

    $(document).ready(function(){
        $(".ui-dialog-titlebar").hide();
    });
    
    0 讨论(0)
  • 2021-01-26 05:19

    That's not javascript, but jQuery:

    You can simply use hide() method:

    $(".ui-dialog-titlebar-close").hide(); // you can also use css() method as yours
    

    And you need to wrap your code inside ready handler:

    $(document).ready(function(){
    //your code here
    });
    

    You can learn more about jQuery here.

    0 讨论(0)
  • 2021-01-26 05:19

    ideally hiding with ID would be more flexible way.

      <div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" id="hidingDiv">
            <span id="ui-dialog-title-dialog-message" class="ui-dialog-title"></span>
            <a class="ui-dialog-titlebar-close ui-corner-all" href="#" role="button">
                <span class="ui-icon ui-icon-closethick">close</span>
            </a>
        </div>
    

    JS code for hiding:-

        $(document).ready(function() {
            $("#hidingDiv").hide();
        });
    
    0 讨论(0)
  • 2021-01-26 05:24

    you have so many ways

    $(".ui-dialog-titlebar").hide();
    $(".ui-dialog-titlebar").fadeOut();
    $(".ui-dialog-titlebar").css('display','none !important');
    
    0 讨论(0)
  • 2021-01-26 05:24

    Put it in document.ready():

    $(function(){
    
     $(".ui-dialog-titlebar-close").css('display','none');
    
    })
    

    and you can also use hide():

    $(function(){
    
         $(".ui-dialog-titlebar-close").hide();
    
    })
    

    FIDDLE EXAMPLE:

    http://jsfiddle.net/qcfdLjr3/

    0 讨论(0)
  • 2021-01-26 05:29

    you can use you own code as:

    $(document).ready(function(){
        $(".ui-dialog-titlebar").css('display','none');
    

    or $(".ui-dialog-titlebar").hide(); });

    because before doing all there document should be ready.

    0 讨论(0)
提交回复
热议问题