javascript - jQuery is swapping the tags that I insert -


i have following html:

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

and following jquery code:

$('> ul li', body).each(function() {   $('</ul><ul>').insertbefore($(this)); }); 

this code should insert closing tag followed opening tag unordered list in front of each list item, instead inserts <ul></ul>. these wrong way around! why jquery , know how solve problem?

jquery not inserting html markup somewhere. manipulating dom - , that, $('</ul><ul>') somehow parsed element gets insertedbefore(this). since </ul><ul> invalid markup, browser best when trying parse , comes <ul/> then, gets inserted in document.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -