wrap 6 li elements together on a long list

Posted by blackhandr on Stack Overflow See other posts from Stack Overflow or by blackhandr
Published on 2010-03-22T09:32:16Z Indexed on 2010/03/22 19:31 UTC
Read the original article Hit count: 375

Filed under:

I have a long list like this:

<ul>
    <li>item 1</li>
    <li>item 2</li>
    <li>item 3</li>
    <li>item 4</li>
    <li>item 5</li>
    <li>item 6</li>
    <li>item 7</li>
    <li>item 8</li>
    <li>item 9</li>
    <li>item 10</li>
    <li>item 11</li>
    ...
</ul>

and I want to somehow wrap some divs around them like this:

<ul>
    <div>
        <li>item 1</li>
        ...
        <li>item 6</li>
    </div>

    <div>
        <li>item 7</li>
        ...
        <li>item 12</li>
    </div>

    <div>
        ...
    </div>
</ul>

How can I accomplish this?

I tryed .after('</div><div>'); but it's not working, it adds a <div></div>.

© Stack Overflow or respective owner

Related posts about jQuery