Get tag names and first child data using jQuery

Hi, I am trying to extract data from a child of a tag from my ajax script. this works with javascript

coursename = xmlDocument.getElementsByTagName("sitelist");
name = coursename[3].firstChild.data 

Can someone help me with doing this using jQuery please? I thought this would work, but it is not.

name = $("coursename", xml).text()

Any help or pointers would be great, thanks.

+3
source share
2 answers
$('sitelist:eq(2)')

is a jQuery selector. You might want to use the jQuerys method .data()to save something in this node.

+2
source
name = $("sitelist", xmlDocument).eq(3).children(":first").text();

above uses:

+1

Source: https://habr.com/ru/post/1765378/


All Articles