Don't hide the element if the second block is pressed.
-
Here's an example of work. http://jsfiddle.net/ghkEY/98/
$('.nav__top-level li').click(function(){ var links = $('.sub-menu li').children(); var arrLinks = []; links.each(function(index,element) { if(index >= 1) arrLinks.push($(element).attr('href'));'' }); $('#sub-menu a').each(function(index,element){ $(element).attr('href',arrLinks[index]); console.log(arrLinks); }); });
<nav class="nav nav__top-level"><ul id="menu-top-menu" class=""> <li id="menu-item-134" class="menu-item-has-children"><a href="#">Сервис</a> <nav id="sub-menu" class="nav nav__second-level" style="display:none;"> <ul> <li id="menu-item-131" ><a href="http://excellence-new.ru/category/bez-rubriki/">Без рубрики</a></li> </ul></nav> </li> <li id="menu-item-15" class="menu-item-has-children"><a href="#">instagram</a> <nav id="sub-menu" class="nav nav__second-level" style="display:none;"> <ul> <li id="menu-item-132" ><a href="http://excellence-new.ru/category/obuv-i-aksesuari/">Обувь и Аксессуары</a></li> <li id="menu-item-133" ><a href="http://excellence-new.ru/category/odejda/">Одежда</a></li> </ul></nav> </li> </ul></nav>
<nav class="nav nav__second-level" > <ul id="sub" style="display:none;"> </ul> </nav></code></pre></div></div></p><p>How to replace the current elements with an open menu with another main paragraph of the menu, but the animation would not or would not have worked or solved the new one. ?</p>
-
$('#sub').html(newLinks); if ($(this).hasClass('activeMenu')){ $('.nav__second-level').children('#sub').slideUp('slow'); $(this).removeClass('activeMenu'); } else{ $('.nav__second-level').children('#sub').hide().slideDown('slow'); $('.menu-item-has-children').removeClass('activeMenu'); $(this).addClass('activeMenu'); }
Updated the fed.
http://jsfiddle.net/moonvvell/ghkEY/101/