How to loop through a jquery each loop using filter :eq for an unknown range?
for example, I would like to loop through the following:
$("#list li:eq("+ i +")").each(function(i)
{
i++;
});
This code does not work
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The above code has two obvious flaws:
ibefore you assign it a value, and$('#list li:eq(' + i + ')')will only ever return one result (thelithat’s equal to whatever valueiholds.To iterate through the
lielements, simply use:If you need to work only on elements that are equal to a particular value of
i:Or simply:
If you have specific requirements then please add those to the question, so that we can better help you with this.