js -> 通过 标签 的某一个 属性值 获取另外一个 属性值

 

 

依照 

 

<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub">

 执行

 

 

document.querySelector("link[rel=search]").getAttribute("href") 

 

 

就可以获取到 /opensearch.xml

 

参考: 

 

https://stackoverflow.com/questions/9441928/how-to-get-attribute-from-a-link-tag-in-pure-javascript

 

支持的浏览器 

http://caniuse.com/#feat=queryselector

 

 

猜你喜欢

转载自mft.iteye.com/blog/2378327