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 :hidden
help 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?
精彩评论