wrapall

WrapAll() on multiple classes with multiple appearance

自作多情 提交于 2020-01-11 09:25:09
问题 Lets say this is my HTML <ul class="products> <li class="product"> <div class="product-title></div> <div class="product-thumbnail></div> <div class="product-price></div> <div class="product-discription></div> </li> <li class="product"> <div class="product-title></div> <div class="product-thumbnail></div> <div class="product-price></div> <div class="product-discription></div> </li> </ul> Now I want to wrap .product-thumbnail and .product-price in <div class="left"></div> Like this <ul class=

Wrap multiple div elements on same class

僤鯓⒐⒋嵵緔 提交于 2019-12-29 00:07:26
问题 I would like to use jQuery to wrap sets of class elements in a div but can't find the solution. HTML: <div class="view-content"> <div class="first">content</div> <div class="first">content</div> <div class="second">content</div> <div class="third">content</div> <div class="third">content</div> </div> Desired Result: <div class="view-content"> <div class="column"> <div class="first">content</div> <div class="first">content</div> </div> <div class="column"> <div class="second">content</div> <

jQuery: Wrap only first and second child, not the rest of children

▼魔方 西西 提交于 2019-12-24 17:00:04
问题 In my actual code: <div id="mother"> <div id="child-01"></div> <div id="child-02"></div> <div id="child-03"></div> </ul> I need to produce: <div id="mother"> <div id="myWrap"> <div id="child-01"></div> <div id="child-02"></div> </div> <div id="child-03"></div> </ul> I was playing with wrap, . wrapAll() and children, but I'm stuck. If in my actual code i have: <div id="mother"> <div id="child-01"></div> <div id="child-02"></div> <div id="child-03"></div> </ul> <div id="uncle"> <div id="cousin

Wrapping range of children elements in a div

こ雲淡風輕ζ 提交于 2019-12-22 06:42:17
问题 I'm trying to wrap a range of children elements in div in order to manipulate them in groups; trying to position each group in a different place. The scenario is that I have a list randomly generating li tags and no matter how many appear I need every set of ten to be manipulated separately. To figure this out I'm using a written out list: $("ul li ul li:nth-child(n+11)").wrapAll("<span class='shift' />"); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"><

jQuery nextUntil include text nodes

为君一笑 提交于 2019-12-17 19:44:24
问题 I'm using nextUntil method to get all stuff between two elements. But this method does not include text nodes to output. It gives an array like [<br>, <br>, <br>] . How can I get all stuff including text nodes? This is the HTML code: $('.content a:contains("spoiler").b:even').each(function() { $(this).nextUntil('.content a:contains("spoiler").b') .wrapAll('<div style="border:solid 1px black;"></div>'); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"><

jQuery wrap multiple elements independent of level

↘锁芯ラ 提交于 2019-12-12 08:59:07
问题 This is my first post on stackoverflow. So far I could always find an answer here, but this time I couldn't. Here is my DOM structure: <div id="elementA"> <div id="elementB"></div> <div id="elementC"> <div id="elementD"></div> </div> <div id="elementE"></div> </div> How can I wrap 2 or more selected "random" elements into a wrapper container? This should also work if the selected elements are on different level and if there are other elements in between. The DOM structure of all other

How to wrap h1 and follow content in div? [duplicate]

元气小坏坏 提交于 2019-12-10 21:43:13
问题 This question already has answers here : Wrap HTML with DIV until next H3 (2 answers) Closed 6 years ago . I need to know how to wrap h1 and follow content in div . This is the original structure: <h1>Title #1</h1> <p>Text</p> <p>Text</p> <h1>Title #2</h1> <p>Text</p> <p>Text</p> <p>Text</p> <h1>Title #3</h1> <p>Text</p> This is the result I want to get : <div> <h1>Title #1</h1> <p>Text</p> <p>Text</p> </div> <div> <h1>Title #2</h1> <p>Text</p> <p>Text</p> <p>Text</p> </div> <div> <h1>Title

Trying jQuery wrapAll seems to wrap the content twice

不羁岁月 提交于 2019-12-10 19:43:25
问题 I got a markup looking like this : <body> <... a lot of tags from the web site ...> <script type="text/javascript" src="http://cdn.jquerytools.org/1.1.1/jquery.tools.min.js"></script> <script type="text/javascript" src="my_script.js"></script> <body> I want it to end up that way : <body> <div id="body-content"> <... a lot of tags from the web site ...> <script type="text/javascript" src="http://cdn.jquerytools.org/1.1.1/jquery.tools.min.js"></script> <script type="text/javascript" src="my

Wrapping consecutive list items in separate groups using jQuery

喜你入骨 提交于 2019-12-10 17:09:47
问题 I have an unordered list exported by a CMS and need to identify <li> elements that have the class .sub and wrap them in a <ul> . I have tried the wrapAll() method but that finds all <li class="sub"> elements and wraps them in one <ul> . I need it to maintain seperate groupings. The exported code is as follows: <ul> <li></li> <li></li> <li></li> <li class="sub"></li> <li class="sub"></li> <li class="sub"></li> <li></li> <li></li> <li class="sub"></li> <li class="sub"></li> <li class="sub"></li

Wrapping range of children elements in a div

蓝咒 提交于 2019-12-05 10:33:51
I'm trying to wrap a range of children elements in div in order to manipulate them in groups; trying to position each group in a different place. The scenario is that I have a list randomly generating li tags and no matter how many appear I need every set of ten to be manipulated separately. To figure this out I'm using a written out list: $("ul li ul li:nth-child(n+11)").wrapAll("<span class='shift' />"); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div id="access"> <div class="menu"> <ul> <li> <p>Hello</p> <ul> <li>Stuff</li> <li>Stuff</li> <li