Sources: How to create an array from .each loop with jQuery et How to generate UL Li list from string array using jquery?.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function addHeaderTopRowLinksToMegadropdownXS() { var headerHorizontalNav01 = []; $cdDropdownContent = $('ul.cd-dropdown-content', '#xsMegaDropdown'); $('.yCmsComponent', '#page-header').each(function(){ headerHorizontalNav01.push($(this).html()); }); $.each(headerHorizontalNav01, function(i) { $('<li class="has-children">'+headerHorizontalNav01[i]+'</li>') .appendTo($cdDropdownContent); }); } |