I've been scouring the web for hours trying to find a solution to this that works for me but I just can't seem to find one.
I need an image ([alt="post-banner"]
) to be moved into #blog-banner-container. The problem is, all the images with that alt get moved into the first div. I'm presuming I have to use .closest()
but I don't know how to use it.
jQuery
$('[alt="post-banner"]').appendTo('#blog-banner-container');
HTML
<div class="blog-entry">
<div id="blog-banner-container"></div>
<div class="blog-entry-title">Title</div>
<div class="blog-entry-body">
<img src="#" alt="post-banner" />
</div>
</div>
<div class="blog-entry">
<div id="blog-banner-container"></div>
<div class="blog-entry-title">Title</div>
<div class="blog-entry-body">
<img src="#" alt="post-banner" />
</div>
</div>
<div class="blog-entry">
<div id="blog-banner-container"></div>
<div class="blog-entry-title">Title</div>
<div class="blog-entry-body">
<img src="#" alt="post-banner" />
</div>
</div>