I have the code bellow inside a wordpress loop, so the variable $perf and $url change every time.
<div class="link" data-performer="<? echo $perf; ?>">
<a class="performer_rp" href="<? echo $url; ?>">My anchor</a>
</div>
This jquery function ads the variable $perf to the link, on click.
function performer_rp(){
var perf;
perf = $(".link").data('performer');
$("a.performer_rp").click(function() {
this.href += "?perf="+perf+"";
});
};
Problem is, I get only the first value of $perf, it won’t change with the loop.
So lets say the loop “loops” 5 times and I get 5 $perf values: value1, value2 … value5.
The jquery code asigns the value1 everytime.
Why is that?
Ty very much!
Well ‘id do it this way:
otherwise you have the same perf each time (because it’s not relative to the link you click), and you are getting a collection of perfs anyway.
Edit: i don’t know exactly how data() works, but i think you could use: