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,429
  • 2
  • 19
  • 37
Learning
  • 18,542
  • 37
  • 165
  • 337

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,204
  • 14
  • 23