Reputation: 3941
I am using jquery to dynamically create an active state using Flexslider's API. Here is my jQuery:
var curslide = slider.animatingTo;
var parsed = parseInt(curslide);
$("#pillarControl li").each(function(){
$(this).removeClass("active");
});
$("#pillarControl li a[rel='parsed']").parent().addClass("active");
THe bottom line is NOT working. If I replace parsed
with an actual integer, it works great. But for some reason, the variable parsed
is not causing the active class to be added. I did a test to see if the variable parsed
had the correct value stored, and it does. Seems to be a syntax problem? Not sure, any ideas?
Upvotes: 0
Views: 181
Reputation: 55750
You seem to be passing parsed as a string . You need to pass the
var parsed = parseInt(curslide);
So your old selector is looking with rel="parsed"
and not the value of parsed..
$("#pillarControl li a[rel='" + parsed + "']").parent().addClass("active");
Upvotes: 0
Reputation: 98
Try this:
$("#pillarControl li a[rel='" + parsed + "']").parent().addClass("active");
Upvotes: 0
Reputation: 14521
The problem is that you don't pass the variable value, but just 'parsed' as text. Try:
$("#pillarControl li a[rel='" + parsed + "']").parent().addClass("active");
Upvotes: 5