I want to add a rel attribute of the element matching the array, so for example the array is:
var targetVal = ['1','2','4'];
And 5 elements with the same class:
<a class="link" href="1.html">
<a class="link" href="2.html">
<a class="link" href="3.html">
<a class="link" href="4.html">
<a class="link" href="5.html">
I want to target the 2nd, 3rd and 5th line with a rel attribute.
$(".link").each(function(index) {
$(this).attr("rel", "group");
});
How can I make the above script index through based on the array?