I have in a div Container some News Articles with and without images. Now want to add for each article without image a different class. If there is an image, the image is wrapped with <div class="news-img-wrap"></div>
. Articles with no images don't have this div
. So i try this
$('.news-list-view article .content-background').each(function () {
if ($(this).find('.news-img-wrap').length) {
$(this).addClass('colored-box-red ');
} else {
$(this).addClass('default-box');
}
});
This code works fine for all articles with image get the extra class. My Question is how i can give each article with image an different extra class "first,second,third"
My example till now.http://jsfiddle.net/b9JuT/
thanks for your help and sorry for my bad english.