There is a type menu

<ul class="menu"> <li>Пункт меню 1</li> <li>Пункт меню 2 <ul class="submenu"> <li>Подпункт 1</li> <li>Подпункт 2</li> </ul></li> </ul> 

The class ".menu" has a style, for example, "height: 100px;". It is necessary to do that the IF item has a submenu of the class ".submenu", the style of the general menu has changed. For example, "height: 20px;". I will be glad to advice!

  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

You can make it easy. We are looking for submenus ourselves, then we are looking for a menu in the parents, we add a menu class with changed styles

 $(function(){ $('.submenu').parents('.menu').addClass('changed-styles'); });