Jump to content

jQuery wrapAll()


anevins

Recommended Posts

Hello,

 

I want to wrap two html elements with a <div>.

 

I want only the <img> that has a next sibling '<div class="last">' and vice versa.

 

$('.main img ~ div.last').wrapAll('<div></div>');

 

I've tried adding

$('.main img ~ div.last').prev().next().wrapAll('<div></div>');

But that just wraps the next sibling, not including the previous.

 

Could someone point me in the right direction?

Link to comment
https://forums.phpfreaks.com/topic/266492-jquery-wrapall/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.