Jquery - How to get the style display attribute “none / block”

后端 未结 5 611
深忆病人
深忆病人 2021-01-30 04:08

Is there a way to get the style: display attribute which would have either none or block?

DIV :

相关标签:
5条回答
  • 2021-01-30 04:11

    this is the correct answer

    $('#theid').css('display') == 'none'
    

    You can also use following line to find if it is display block or none

    $('.deal_details').is(':visible')
    
    0 讨论(0)
  • 2021-01-30 04:19
    //animated show/hide
    
    function showHide(id) {
          var hidden= ("none" == $( "#".concat(id) ).css("display"));
          if(hidden){
              $( "#".concat(id) ).show(1000);
          }else{
              $("#".concat(id) ).hide(1000);
          }
      }
    
    0 讨论(0)
  • 2021-01-30 04:22

    My answer

    /**
     * Display form to reply comment
     */
    function displayReplyForm(commentId) {
        var replyForm = $('#reply-form-' + commentId);
        if (replyForm.css('display') == 'block') { // Current display
            replyForm.css('display', 'none');
        } else { // Hide reply form
            replyForm.css('display', 'block');
        }
    }
    
    0 讨论(0)
  • 2021-01-30 04:32

    You could try:

    $j('div.contextualError.ckgcellphone').css('display')
    
    0 讨论(0)
  • 2021-01-30 04:37

    If you're using jquery 1.6.2 you only need to code

    $('#theid').css('display')
    

    for example:

    if($('#theid').css('display') == 'none'){ 
       $('#theid').show('slow'); 
    } else { 
       $('#theid').hide('slow'); 
    }
    
    0 讨论(0)
提交回复
热议问题