JQuery closes my open tags
When I add html to my page as an open tag, jquery is closing the tag for me, how to i stop this?
The reason im doing this is I have a series of divs and I need li tags around every 2 divs. So I have this;
div1
div2
div3
div4
And I need this;
<li> div1 div2 </li>
<li> div3 div4 </li>
I can see the code is being applied in the correct place with this;
window.onload = function(){
$(".mydiv:even").before( "open li ");
$(".mydiv:odd").after("close li");
}
However, If i change the text to the actual mark up, as soon as a li is opened on the page it is also closed.
window.onload = function(){
$(".mydiv:even").before( "<li>");
$(".mydiv:odd").after("</li>");
}
So I get something like this;
<li></li>
div1
div2
<li></li>
div3
div4
<li></li>
How can I make jquery respect open li tags?
Thanks