call value of an attribute in a loop with Jquery

here is my situation,

i have a loop with multiple post, I would like by jquery to add the link previously call in a new div created by js.

It look something like this:

if ($(this).hasClass(’64’)){

$(this).append(‘<a class=”video-post-archive” href=””>Watch the video</a>’);

bascially in the above, I add a add a new div, which will contain a href value call from the post.

for this i declare a variable like:

var newlink = $(“.widgetizedArea ul li a”).attr(“href”)

And then call the value in the append div like:

if ($(this).hasClass(’64’)){

$(this).append(‘<a class=”video-post-archive” href=””>Watch the video</a>’);

$(this).find(‘a.video-post-archive’).attr(‘href’, newlink);

}

The problem im having is that it repeat the same link for all the post from the loop . ..

Example: Item 1 link fins, but item 2 link to item 1 content, item 3 link to item 1 content instead of their own content . . .

Any idea to help me with that ?

It will be brilliant !

Thanks for all 🙂

Read more here:: call value of an attribute in a loop with Jquery

Leave a Reply

Your email address will not be published. Required fields are marked *