tags:

views:

30

answers:

1

I'm tryng to do

$('input').change(function() {
   $('a').removeAttr('href');
});

And this works like you would think it would, except that it still leaves an empty a tag. I'd like to unwrap the a tag all together. I tried:

$('input').change(function() {
   $('a').unwrap();
});

But I think that removed the parent element, not the anchor tag itself.

+1  A: 
$('a').after($('a').text());
$('a').remove();

UPDATE:

if you actually need to do this for every a tag and not just a specific one (i don't see why you would, but just in case)...

$('a').each(function(){$(this).after($(this).text());});
$('a').remove();
Brandon H
Ah, thank you for the update. The reason why I needed it for every anchor tag is because I don't want the user to enter something into a field and then navigate away from the page without pressing the submit button.
cf_PhillipSenn