0

I have a dropdown menu on hover i show different background color for li which has div present with class dropdown and different color for li which dont have sub menu wrapped inside div

<ul class="nav">
<li>
   <a href="page1"> page one</a>
</li>
<li>
   <a href="page2"> page one</a>
   <div class="dropdown"> .....</div>
</li>
<li>
   <a href="page3"> page one</a>
</li>
<ul>

I want to target only li which don't have any sub menu or in other words div present with class class="dropdown".

I know this can be achieved using jquery using hasClass but i want to do this using css only.

Vitorino fernandes
  • 15,794
  • 3
  • 20
  • 39
Learning
  • 19,469
  • 39
  • 180
  • 373

1 Answers1

0

If you want to separate style and scripting, your best bet is to check for the dropdown class with jQuery and add a class to its parent (e.g. contains_dropdown). Give that class contains_dropdown the style you want.

user3154108
  • 1,264
  • 13
  • 23