I am having problems with the each() function. What I like to is to return false; and then start up again. You’ll see the each() function is repeating only the first link. I would like the each link to clone each $(‘.ms-PostTitle a’) … See my code. Please Help!
========HTML======= What the each() function is currently doing 🙁 ….
<div class="ms-PostTitle">
<a href="Post.aspx?ID=1">Post #1</a>
</div>
<a href="Post.aspx?ID=1" class="read-more">Read More</a>
<div class="ms-PostTitle">
<a href="Post.aspx?ID=2">Post #2</a>
</div>
<a href="Post.aspx?ID=1" class="read-more">Read More</a>
========HTML======= What I like it tooo doo….
<div class="ms-PostTitle">
<a href="Post.aspx?ID=1">Post #1</a>
</div>
<a href="Post.aspx?ID=1" class="read-more">Read More</a>
<div class="ms-PostTitle">
<a href="Post.aspx?ID=2">Post #2</a>
</div>
<a href="Post.aspx?ID=2" class="read-more">Read More</a>
========jQuery=======
$('.ms-PostTitle a').each(function () {
var href = $(this).attr('href');
$('<a class="read-more" href=' + href + '>Read More</a>').insertAfter('div.ms-PostBody p');
return false;
});
This should work
http://jsfiddle.net/RLa5C/1/