0

I have a script that strips a long unordered dropdown menu list into groups of 5, and appends them, with a parent ul back into their original li. This is the html at present.

<li class="dropdown menuB">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Drobdown B<b class="caret"></b></a>
    <ul class="dropdown-menu row-fluid">
        <li><a href="#">Link 1</a></li>
        <li><a href="#">Link 2</a></li>
        <li><a href="#">Link 3</a></li>
        <li><a href="#">Link 4</a></li>
        <li><a href="#">Link 5</a></li>
        <li><a href="#">Link 6</a></li>
        <li><a href="#">Link 7</a></li>
        <li><a href="#">Link 8</a></li>
        <li><a href="#">Link 9</a></li>
        <li><a href="#">Link 10</a></li>
        <li><a href="#">Link 11</a></li>
        <li><a href="#">Link 12</a></li>
    </ul>
</li>

jQuery(function(){
    var $bigList = jQuery('.menuB .dropdown-menu'), group;
    while((group = $bigList.find('li:lt(5)').remove()).length){
        var $ul = jQuery('<ul/>'),
        $eachLi = jQuery('<li/>', {class: ( 'span' + spanSize )});          
        $ul.append(group);
        $eachLi.append($ul);
        jQuery(".dropdown-menu").append($eachLi);
    }
});

If i append the new list anywhere else in the html, i.e. the body, a different li it works just fine, however when i append it back to the lists parent ul it crashes my browser, in every browser i have tried. Why am i not able to reappend to the original parent?

codingrose
  • 15,563
  • 11
  • 39
  • 58
Tim Wilkinson
  • 3,761
  • 11
  • 34
  • 62

0 Answers0