Grouping Siblings Into A Div
I am working for a company that is using a very oddly coded ecommerce solution. I do not have direct access to the code of the ecommerce store as it is hosted by that specific comp
Solution 1:
try this
HTML
<table><tbody><tr><tdclass="Product"><divclass="ProductWrapper"><aclass="ProductThumb"href="#"><imgsrc="#" /></a><aclass="ProductName"href="#">Example</a><metaitemprop="name"content="Example""=""><divclass="Status"><linkhref="#">
In Stock
</div><divclass="Price"><b>$0.00</b><metaitemprop="priceCurrency"content="USD"></div></td><tdclass="ProductSpacer"><div></div></td><tdclass="Product"></td></tr></tbody></table>
JS CODE
$(".ProductThumb").siblings('.Price').wrapAll("<div class='ALLNEW' />");
Solution 2:
Try it like that: wrap the content of your selector:
$(".ProductThumb").parent().wrapinner("<div class='ALLNEW'>");
Or even simpler:
$(".ProductWrapper").wrapinner("<div class='ALLNEW'>");
Edit:
If you want to exclude all anchor and image tags you can use the :not()
filter and change the logic a bit:
$(".ProductWrapper").children(":not(a, img)").wrapAll("<div class='ALLNEW'>");
Post a Comment for "Grouping Siblings Into A Div"