Answer the question
In order to leave comments, you need to log in
How to display elements on button click with jQuery?
Hello. There are several divs, for example 6 pieces
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
Answer the question
In order to leave comments, you need to log in
So:
$('#count-blocks').on('click', function(ev) {
ev.preventDefault();
var hiddenBlocksQuantity = 0;
$('div').each(function() {
var isHidden = ($(this).css('display') === 'none');
if (isHidden) {
hiddenBlocksQuantity++;
}
})
alert ('There is ' + hiddenBlocksQuantity + ' hidden blocks');
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question