Jquery selector for <link> elements in <head>

前端 未结 4 719
囚心锁ツ
囚心锁ツ 2020-12-30 06:06

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 el

4条回答
  •  轮回少年
    2020-12-30 06:22

    jQuery can't do it, but your browser can: (Do not try to parse HTML with a regex as someome suggested.)

    txt = '
    ajelo
    '; if(window.DOMParser) { parser=new DOMParser(); xmlDoc=parser.parseFromString(txt,"text/xml"); } else { // Internet Explorer xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.loadXML(txt); } xmlDoc.getElementsByTagName('LINK');

    Be aware that XML is case sensitive, so you need to search for 'LINK' using the same case as it is in the HTML.

提交回复
热议问题