New to jQuery, I have a script that returns data from an XML file. What I need is the index number of the element returned. I know I can retreve a single element with this
name = $("sitelist:eq(1)",data).text();
but in my script I need to know each element position for the displayed data. something like position = $(data,eq).value .Can anyone help please .
$(document).ready(function () {
$.ajax({
type: "GET",
url: "sites.xml",
dataType: "xml",
success: displayXml
});
function displayXml(data) {
$(data).find("course").each(function () {
var name = $(this).find("sitelist").text();
var line1 = $(this).find("address1").text();
});
}
}); // doc ready