I am trying to get the two randomly generated div ID's shown below and wrap them within my custom div that I can control. Was searching around on jQuery API for solution but still no ideas.
Here's a preview of example:
Okay so as you can see, there are two <div id="random_string"></div>
and one custom <div class="wrap_awm"></div>
Since I can't target the two ID's from above I have no clues how to tell jQuery, get the two div's from above wrap_awm and put them inside of the ".wrap_awm". Simple as that?
What you're looking for is called .prevAll()
:
var $wrap = $('.wrap_awm');
$wrap.prevAll(':lt(2)').appendTo($wrap);
It's combined with the :lt()
selector to only use the first two elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With