Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
124
rated 0 times [  125] [ 1]  / answers: 1 / hits: 21427  / 15 Years ago, thu, july 2, 2009, 12:00:00

I have been trying to find out why the following lines of code do not work:



$('#add-cloud > select').change(function() {
var selected = parseInt($('#add-cloud select option:selected').val());
$(#cloud-calculator table tr:eq(selected)).css(color, red);
});


If I change :eq(selected) to :eq(4) for example - works fine. How do you pass variable as an argument to :eq() ?


More From » jquery

 Answers
121

You have to concatenate your variable with your selector:



$(tr:eq(+selected+));

[#99199] Saturday, June 27, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deanna

Total Points: 84
Total Questions: 86
Total Answers: 107

Location: Cyprus
Member since Wed, Dec 8, 2021
3 Years ago
;