2

I have html like this:

<div class="first">
    <div class="second home">
    </div>
</div>
<div class="first">
    <div class="second">
    </div>
</div>

Is it possible to style div element with class first if child div has home class?

mattis
  • 211
  • 3
  • 10

2 Answers2

1

Can do it using jquery

$($('.home').parent('div')).addClass('first');
JTN
  • 229
  • 5
  • 13
0

try something like this

$('.home').parent('div').addClass('first');

All child element with home than

    $('.home').each(function(){
        $(this).parent('div').addClass('first');
    });
rajesh kakawat
  • 10,826
  • 1
  • 21
  • 40