break jquery $('<div>') into separate opening and closing tags
I have several blocks like:
<div class="first">...</div>
<div class="second">...</div>
<div class="third">..</div>
I want to wrap all 3 blocks with another div. Is there a way to split $('</div>') in two parts: <div> and </div> so I could insertBefore() the opening <div> and insertAfter() the closing </div>开发者_如何学JAVA; I could achieve it simply with html but I can't modify it in this situation
Could you use 'wrapAll()'?
$('div').wrapAll('<div class="new" />');
Not sure I'm understanding you correctly, but you should be able to store the elements in variables, and add the new elements to them like this.
var el1 = $("div")
var el2 = el.add("div");
var el3 = el2.add("div");
精彩评论