Instead of iterating through every a
, you can iterate through only a
s which have that particular href
attribute by altering the selector string:(无需遍历每个 a
,您可以通过更改选择器字符串来仅遍历具有特定href
属性a
s:)
$('a[href="/remove/thehrefvalue?when=now"]').remove();
$('a[href="/remove/thehrefvalue?when=now"]').remove();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <a href="/remove/thehrefvalue?when=now">now</a> <a href="/remove/thehrefvalue?when=now">now</a> <a href="/remove/thehrefvalue?when=notnow">notnow</a> <a href="/remove/thehrefvalue?when=now">now</a>
(Not entirely sure what you're looking for. If you wanted to remove the <a>
s, use the code above - if you wanted to remove the attributes but leave the <a>
s alone, use removeAttr('href')
instead of .remove()
)((不完全确定您要查找的内容。如果要删除<a>
,请使用上面的代码-如果要删除属性,但不使用<a>
,请使用removeAttr('href')
而不是.remove()
))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…