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? Quote 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>"); Quote Link to comment https://forums.phpfreaks.com/topic/266492-jquery-wrapall/#findComment-1365697 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.