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: 
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
Post a Comment