Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
84
rated 0 times [  87] [ 3]  / answers: 1 / hits: 27024  / 13 Years ago, fri, october 14, 2011, 12:00:00

I have two selectors



    var allNodes = $(a.historyEntry);
var errorNodes = $(a.historyEntry.error);


I would like to to find a node before first error node, so I need to find an index of first error node, how to do it?



I tried to use inArray method, but it doesn't work for this



$.inArray(allNodes, errorNodes.first())


or



$.inArray(allNodes, $(errorNodes.first()))


Is there any fast way to do it in jQuery or do I have to use for loop?


More From » jquery

 Answers
119

index()?



It's like indexOf... but just without the Of... it returns the index of the element if it exists, and -1 if it doesn't.


[#89609] Thursday, October 13, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
danalexc

Total Points: 114
Total Questions: 119
Total Answers: 103

Location: Hungary
Member since Wed, Nov 9, 2022
2 Years ago
;