Not sure I can explain this properly….
I have the following sequence of code repeated over and over:
<div class="featured">
<div class="link1">
<a href="url1">anchor1</a>
</div>
<div class="link2">
<a href="url2">anchor2</a>
</div>
</div>
...... this sequence is repeated again and again, but "url2" has different values
I am trying to replace “ancor1” with “url2” (for each repeated sequence, url2 has a different value).
I have used this jquery code:
$(".featured").each(function(){
var url2 = $(.featured .link2 a).attr('href');
$("link1").html(url2);
});
The code kinda works but it gets the “url2” value from the first sequence of code and repeats it on every itteretion.
Any ideas?
You need:
This will specify that
.link2and.link1needs to be from the currentfeatureddiv. The second parameter to jQuery specifies the context to search within.