我想基于rel attr的值获取href属性值。如何在javascript中执行此操作?
<links>
<link href="https://someurl/index/16380" rel="self"/>
<link href="https://someurl/index/16380/streams?lang=en" rel="streams"/>
<link href="https://someurl/index/16380/bif" rel="bif" />
</links>
沿线的东西....
$(xml).find('link').each(function(){
if(rel == 'streams'){
this.streamurl = $(this).attr('href');
}
});
$(xml).find('link').each(function(){
//prevents your re-wrapping this multiple times
var $this = $(this);
//read the attribute
if($this.attr('rel') == 'streams'){
this.streamurl = $this.attr('href');
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句