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
Post a Comment