Search code examples
jquerycontain

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

Solution

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