Question
What are ways to add dynamic elements to wrap list items and apply a class?
Current research
I found this on the official docs from jQuery.
Which gave an example
<script>
$( "span:nth-of-type(2)" )
.append( "<span> is 2nd sibling span</span>" )
.addClass( "nth" );
</script>
But that only discussed adding a class to an individual element. I want to wrap multiple elements
Default code with generated items
<ul>
<!-- These items will be dynamically generated-->
<li>First</li>
<li>Second</li>
<li>Third</li>
<li>Fourth</li>
<li>Fifth</li>
<li>Sixth</li>
</ul>
What the current code would produce
Desired outcome
<ul>
<div class="row">
<li>First</li>
<div class="right">
<li>Second</li>
<li>Third</li>
</div>
</div>
<div class="row">
<div class="left">
<li>Fourth</li>
<li>Fifth</li>
</div>
<li>Sixth</li>
</div>
</ul>
What the desired code would produce (CSS styling defined elsewhere)