anevins Posted July 31, 2012 Share Posted July 31, 2012 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 More sharing options...
anevins Posted July 31, 2012 Author Share Posted July 31, 2012 SOLVED $(".main img ~ div.last").prev().add(".main img ~ div.last").wrapAll("<div></div>"); Link to comment https://forums.phpfreaks.com/topic/266492-jquery-wrapall/#findComment-1365697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.