We use jQuery to parse some HTML. I then need to traverse that document and find some elements. Among the elements I need to find, there are the <link> elements.
This works perfectly well to extract all the <a> elements:
$(string).find("a")
but this doesn’t work to extract the <link> elements :
$(string).find("link")
The string parameter is the html content (e.g. received on a request).
Any idea why? (I guess that the find only applies to the <body> elements). Also, any idea on how to actually extract these <link> elements?
From the documentation of the feature you’re using for
$(string)(which is the functionjQuery( html, [ownerDocument] )):Try not to use jQuery to manipulate entire HTML documents.
Note, in particular, that a
linknode in a standalone snippet of HTML can be “found” just fine.