i'm using:
$('.filter__selector').change(function(){
var sel = $(this).val();
$('.filterItem').hide();
//console.log(sel);
if(sel != "all"){
$('main').find('.projects__entry').hide();
$('main').find('.' + sel).show();
}
else {
$('main').find('.projects__entry').show();
}
}
);
to filter list items with an select
dropdown which works pretty good. the problem is that i'm using the &:nth-child(3n+3)
to style every third list-item differently.
while hide()
removes the items from the screen, it doesn't remove them from the DOM and my css gets screwed. as extra difficulty i want to toggle them back in if the select
dropdown is changed.
for clarification i've created a fiddle: https://jsfiddle.net/9wtt4fge/2/ - the items in the third column should always get blue borders the items in the first two columns have to be red.
i've already found the detach()
method and this question/answer How to toggle elements in and out of DOM using jQuery detach() method? but i can't make it work.
any help is appreciated!