javascript - Grab two randomly generated divs and wrap within custom div -


i trying 2 randomly generated div id's shown below , wrap them within custom div can control. searching around on jquery api solution still no ideas.

here's preview of example: 2 randomly generated id's + custom class

okay can see, there 2 <div id="random_string"></div> , 1 custom <div class="wrap_awm"></div>

since can't target 2 id's above have no clues how tell jquery, 2 div's above wrap_awm , put them inside of ".wrap_awm". simple that?

what you're looking called .prevall():

var $wrap = $('.wrap_awm'); $wrap.prevall(':lt(2)').appendto($wrap); 

it's combined :lt() selector use first 2 elements.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -