这种情况下:我有多个<span>
标签与类.productLink
,与链接(<a>
)包含一个页面的链接。如何通过jQuery在<span>中获取<a>中的href标记?
例
<span class="productLink">
<a href="/Products/Category/item.html">A very nice product</a>
</span>
<span class="productLink">
<a href="/Products/Category/otheritem.html">Also very nice product</a>
</span>
现在我想找回与jQuery这些链接。
我尝试:
$('.productLink').each(function(index){
console.log($(this + ' a').attr('href'));
});
但它投掷:
未捕获的语法错误,不能识别的表达式:[对象HTMLSpanElement]
我必须改变什么?
我错过了一些东西吗? – Satpal
有时会出现不适当的投票结果,而这种情况发生在我身上。 – guradio