I have an XML file setup like so:
<entry name="bob"></entry>
<entry name="ryan"></entry>
<entry name="joe"></entry>
...
<entry name="etc"></entry>
Next, I have a line of code that picks out a name from the XML like so:
var $user= $('entry[images="' + userName + '"]', xml);
But how do I find out what the index of $user is in the overall XML? Example: if userName was ‘joe’, I should get the number ‘2’ back. Any suggestions?
You can use the
.index()method: http://api.jquery.com/index/