我找到了一组使用 jQuery 的 a
标签:
itemsPresent = $('h3.zn-ItemTitle > a');
稍后在我的脚本中,我需要在其 href
属性中找到具有特定 url 的匹配元素中的 a
,而无需进行新的 jQuery 选择。
我该怎么做?
最佳答案
您可以使用 attribute equals
选择器:
itemsPresent = $('h3.zn-ItemTitle > a[href="http://your-url.com"]');
或者,如果您想将它们保留为单独的对象:
var itemsPresent = $('h3.zn-ItemTitle > a'),
filteredAnchors = itemsPresent.filter('[href="http://your-url.com"]');
关于javascript - jQuery,在匹配的元素中搜索具有属性值的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20707836/