开发者

check to see if two ID's are hidden in a conditional

开发者 https://www.devze.com 2023-02-09 19:31 出处:网络
So i have two divs and i want to开发者_JAVA技巧 see if both are currently hidden..Im sure this is really easy but im lost for some reason

So i have two divs and i want to开发者_JAVA技巧 see if both are currently hidden..Im sure this is really easy but im lost for some reason

I have this

    $j('.btn').click(function(){
  //check to see if the divs are currently hidden and if they are show either one of the two    
});


You can use jQuery's :hiddenhelp pseudo along with the .is()help method.

$j('.btn').click(function(){
    var $div1 = $('div.THEDIV'),
        $div2 = $('div.OTHERDIV');

    if( $div1.is(':hidden') && $div2.is(':hidden') ) {
        $div1.show();
    }
});


$('.btn').click(function(){
 var size = $('div#someID').add('div#someOtherID').filter(function(){
  return ($(this).css('display') == 'none' || $(this).css('visibility') == 'hidden');
 }).size();
 if (size == 2) {
  // do your thang baby
 }
});


Use $('#div_1').is(':visible')


if($('.one:hidden') && $('.two:hidden')) {
    $('.btn').click(function(){
      $('.one, .two').show();
    });
  }


<a href="#" class="btn">link</a>

<div class="one">One</div>
<div class="two">Two</div>

Will that do?

0

精彩评论

暂无评论...
验证码 换一张
取 消