0

I need to remove href for the links containing "ext" text

<a id="ctl00_" href="http://www.ext.com/aktiq" target="_blank">Akti</a>

I can't get it working

$("a[href]:contains('ext')").remove();
$("[href]:contains('ext')").remove();
$("href:contains('ext')").remove();
4

2 回答 2

2

使用属性包含选择器

$("a[href*='ext']").removeAttr('href');

您的代码查找anchor具有属性的元素href并包含其中的文本ext,例如<a href=..>..ext...</a>

于 2014-04-25T09:09:59.690 回答
1

您可以使用.removeAttr()从元素中删除属性。试试这个:

 $('a[href*="ext"]').removeAttr('href');

用空的href替换:

 $('a[href*="ext"]').attr('href','');
于 2014-04-25T09:10:15.557 回答