Is there a way to add a class to the element that corresponds to a counter in jQuery?
I currently have this code:
var li_counter = 0;
$("#trigger_heritage").click(function () {
if(heritage_position >= heritage_versatz*13){
li_counter++;
$(".heritage_nav li:nth-child(" + li_counter + ")").addClass("activeheritage");
}
else{ // Something else
}
});
I am trying to add a class to the li-element within the heritage_nav block that matches the counter position. For example, if the user has clicked 5 times, the 5th child element of heritage_nav should receive the class...
Thank you!