So I start with items 1-4:
<div class="someDiv bold italic" style="display: none;">Lorem</div>
<div class="someDiv regular italic" style="display: block;">Lorem</div>
<div class="someDiv bold" style="display: none;">Ipsum</div>
<div class="someDiv regular" style="display: block;">Ipsum</div>
Then I have some input checkboxes:
<input class="regular" type="checkbox" />
<input class="bold" type="checkbox" />
<input class="italic" type="checkbox" />
So basically I have jQuery showing and hiding divs. Now I have another function that must iterate through these divs (one for each checkbox), and show/hide based on another criteria. But I don't want the already hidden divs to be shown again.
$(".someDiv").each(function(){
if($(this).hasClass("regular")){
$(this).show();
} else {
$(this).hide();
};
In this example, the only remaining div should be the last div. Unfortunately, this code will make the second and fourth divs shown.
This code is very basic example of all the filters I'm going to be applying, adding etc.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…