I just want to dynamically put in the index, which is calculating correctly, so I know the value of my variable isn't a problem, but it's not working:
My variable 'parentIndex' stores the index of the span I want to be selecting below. I have tested this variable and it returns the correct value.
$(".DropDownMenu span:eq("+parentIndex+")")
is this not the right way to put a variable into a jquery selector? all the examples i've found use this format, what am i missing?
(The entire function, for context:)
$("span input:radio").click(function() {
if (($(this).is(":checked")) == true) {
var elem = $(this);
var parent = $(this).parent();
var aunts = parent.parent().children();
var parentIndex = aunts.index(parent);
var position = elem.position();
var topValue = position.top;
topValue = topValue - 9;
$(".DropDownMenu").css({ "top": "-" + topValue + "px" });
$(".DropDownMenu span").css("background-image", "none");
parent.css({ "background": "#f3f1e7 url(assets/images/branding/DropDownArrow.gif) no-repeat right" });
$(".DropDownMenu span:eq("+parentIndex+")").css({ "background": "#f3f1e7 url(assets/images/branding/DropDownArrow.gif) no-repeat right" });
}
});