3
How do I append/prepend a div that has a fixed child using jQuery.
For example:
<div class="container">
<div class="placeholder"></div>
</div>
When giving the first append/prepend need that the content is inserted after the .placeholder
. Next should be relative to the element already added.
For example:
Append elem um
<div class="container">
<div class="placeholder"></div>
<div class="elem um"></div>
</div>
Append elem dois
<div class="container">
<div class="placeholder"></div>
<div class="elem um"></div>
<div class="elem dois"></div>
</div>
Prepend elem tres
<div class="container">
<div class="placeholder"></div>
<div class="elem tres"></div>
<div class="elem um"></div>
<div class="elem dois"></div>
</div>
I’ve tried to:
$('.container').find('.placeholder').after().prepend(elem_x);
$('.container').find('.placeholder').after().append(elem_x);
$('.container').find('.placeholder').next().prepend(elem_x);
$('.container').find('.placeholder').next().append(elem_x);
already tried the append without the after?
– Danilo Pádua
Works only for the append, in the prepend the div is inserted before the placeholder.
– Russ_AB