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();
revoua
  • 2,044
  • 1
  • 21
  • 28

2 Answers2

2

Use attribute contains selector

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

Your code looks for anchor elements with href attribute and contains the text ext in it like <a href=..>..ext...</a>

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
1

You can use .removeAttr() to remove attributes from elements.try this:

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

To replace with empty href:

 $('a[href*="ext"]').attr('href','');
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125