javascript - how do you do querySelector for no attributes -


given elements:

<link arbitrary="arbitrary">1st link</link> ... <link>the link want</link> ... 

what queryselector() selector selecting "the link want"? there may number of links arbitrary attributes before or following "the link want", element without attributes. don't want loop through queryselectall() list.

[update] queryselector doesn't require html elements, plain old nodes. working on xml dom loaded atom feed:

var parser = new domparser(); var xmldoc = parser.parsefromstring(xmlsrc, "text/xml"); var xmlelem = xmldoc.documentelement; // fragment: <feed>  <entry>     <link rel='replies' type='application/atom+xml' href='..' title='...'/>     <link rel='replies' type='text/html' href='...' title='...'/>     <link>the link want</link>     <link rel='self' type='application/atom+xml' href='...'/>     <link rel='alternate' type='text/html' href='...' title='...'/>   </entry> <feed> 

there isn't one.

the queryselector() method returns first element matches specified css selector(s) in document.

because there's nothing specific link there isn't way reference on dom in sea of links duplicates.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -