I am currently pulling an RSS feed in which the the format is essentially title->image->text content. I would like to reformat it so that the image comes first. I am currently trying:
<script type="text/javascript">
$(document).ready(function() {
$("li.rssitem").each(function() {
$(".rssdescription a img").remove().insertBefore("h3");
});
});
</script>
HTML looks like:
<ul id="rssitems">
<li class="rssitem"><h3 class="rsstitle"></h3>
<div class="rssdescription"><p><a href="#"><img src="..."></a></p><p>content</p></div></li>
<li class="rssitem"><h3 class="rsstitle">><a href="#">...</a></h3>
<div class="rssdescription"><p><a href="#"><img src="..."></a></p><p>content</p></div></li>
</ul>
Which works except that there are many items (all with images) in the list. This code puts ALL the images before all the h3's. I am clearly having trouble looping correctly. Thanks so much guys!
Try this code :
I didn't tested it, so I'm not sure it will work out of the box, but hopefully you'll be able to modify it to suits your needs.