Quantcast
Channel: Move element inside another (parent with same class) - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Move element inside another (parent with same class)

$
0
0

I'm trying to move an element inside another within the same parentThat parent has siblings with the same class, so I want to apply this on every sibling, but only for their children

At the moment it's taking all title and moving each them inside image, so I end up with 3 title on each element.

What I want is to move just the title of each item inside the image

<div class="item"><a href="" class="image"><img src=""></a><h3 class="title"></h3> <!-- Element to move inside 'image' --></div><div class="item"><a href="" class="image"><img src=""></a><h3 class="title"></h3></div><div class="item"><a href="" class="image"><img src=""></a><h3 class="title"></h3></div>

This is what I've been trying...

$( ".item" ).each(function( index ) {    $(this).find('.title').prependTo('.image');});

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>