Jquery .show() not revealing a div with visibility of hidden

后端 未结 6 1892
情深已故
情深已故 2020-11-29 05:36

Basic jQuery question:

I am trying to reveal a div that has been marked as hidden using jQuery. But am not quite getting it

I\'ve created a JSFi

相关标签:
6条回答
  • 2020-11-29 06:12

    If you have hidden it with visibility:hidden then you can show it with jQuery by

    $(".Deposit").css('visibility', 'visible');
    

    And in the fiddle you are missing jQuery. Here is a demo: http://jsfiddle.net/9Z6nt/20/

    0 讨论(0)
  • 2020-11-29 06:14

    According to JQuery documentation .show() "is roughly equivalent to calling .css('display', 'block'), except that the display property is restored to whatever it was initially." Set the style explicitly instead. You could use a CSS class

    .hidden{
        visibility: hidden;
    }
    .shown{
        visibility: visible;
    }
    

    and set is using

    $("#yourdiv").removeClass("hidden").addClass("shown");
    
    0 讨论(0)
  • 2020-11-29 06:15

    here we go :)

    $(".Deposit").show();
    
        $(".Deposit").fadeOut(500,function(){
            $(this).css({"display":"block","visibility":"hidden"});
    
        });
    
    0 讨论(0)
  • 2020-11-29 06:21

    Hey man your fiddle is working just choose framework jQuery on the fiddle. If its visibility hidden then change the css visibility property to visible.

    (".Deposit").css('visibility','visible');

    0 讨论(0)
  • 2020-11-29 06:25
    $(".Deposit").show();
    
    $(".Deposit").fadeTo(500,0);
    
    0 讨论(0)
  • 2020-11-29 06:27

    If you want the space of the hidden element to be maintained, use opacity.

    i.e:

    $('div').fadeTo(500,1) //show
    $('div').fadeTo(500,0) //hide
    

    for example:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div style='opacity:0'>
      Test opacity
    </div>
    
    
    <button onclick="$('div').fadeTo(500,1);">Show</button>
    <button onclick="$('div').fadeTo(500,0);">Hide</button>

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