Wrapping multiple images inside a <div> in jQuery
- by alekone
hello!
I need to find all the images inside a div, and wrap a div around them.
here's the code I come up with, but that's not working! any ideas?
thanks!
jQuery(function(){
my_selection = [];
$('.post').each(function(i){
if ($(this).find('img').length > 1 ){
my_selection.push(['.post:eq(' + i + ')']);
}
});
$( my_selection.join(',')).wrapAll('<div class="wrapper"></div>');
});