tags:

views:

33

answers:

1

I'm using jQuery to replace matched hyperlinks with their link text. That is:

<a href="http://stackoverflow.com"&gt;Stack Overflow</a>

becomes

Stack Overflow

I'm trying:

$("table.ms-listviewtable a:nth-child(4)").replaceWith($(this).text())

but get a JavaScript error.

Any ideas why and how to fix it?

+3  A: 

"this" isn't what you expect at the time you're executing it.

Something like this should do:

$("table.ms-listviewtable a:nth-child(4)").each(function()
{
    $(this).replaceWith($(this).text());
});
Greg
You are missing a point (literally!), but otherwise it's exactly the same thing I would have suggested, too.
MrMage