revoua
revoua

Reputation: 2059

Remove href containing specific text part

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();

Upvotes: 0

Views: 3120

Answers (2)

Milind Anantwar
Milind Anantwar

Reputation: 82231

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','');

Upvotes: 1

Arun P Johny
Arun P Johny

Reputation: 388316

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>

Upvotes: 2

Related Questions