0

I am trying to wrap each li in a div .new which works fine when the li doesn't have any children <ul><li></li></ul>.

but when it is in following format

<li>XRP 1
    <ul>
        <li>Company Maintenance</li>
        <li>Employees
            <ul>
                <li>Reports
                    <ul>
                        <li>Report1</li>
                        <li>Report2</li>
                        <li>Report3</li>
                    </ul>
                </li>
                <li>Employee Maint.</li>
            </ul>
        </li>
        <li>Human Resources</li>
    </ul>
</li>
<li>XRP 2</li>
<li>XRP 3</li>

It wraps lis in new in the hierarchy several times

$( "li" ).wrap( "<div class='new'></div>" );
.new {
    border:1px solid #ccc; 
    margin:5px; 
}

is there any way that I can add open and closing tag before each item?

xCRKx TyPHooN
  • 808
  • 5
  • 18
Behseini
  • 6,066
  • 23
  • 78
  • 125

1 Answers1

2

If this is what you want to do (I'm not sure):

<ul>
    <div><li></li></div>
</ul>

This is not valid HTML.
Explanation here: Is this HTML structure valid? UL > DIV > { LI, LI } , DIV > { LI, LI } , DIV > { LI, LI }

Community
  • 1
  • 1
Louys Patrice Bessette
  • 33,375
  • 6
  • 36
  • 64