Question

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();
Was it helpful?

Solution 2

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

OTHER TIPS

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>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top