using jquery to change html table attributes

maqskywalker
maqskywalker used Ask the Experts™
on
Hi experts,

I'm using jQuery 1.10.1
I have a html table that looks like this:

my fiddle when i run it
This is my fiddle: https://jsfiddle.net/80LfmsLo/

How do i use jQuery to remove this  <a href="http://www.google.com" target="_blank"></a>  tag from the LastName column values for all the Employees with the title 'Sales Representative'?

I was thinking of using the jquery remove attribute but not sure if that is the best way.
Anyone know how?

So my page should look like this:

my desires result
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software Engineer
Commented:
Try this:
$('#TableEmployees tr:has(td:eq(3):contains("Sales Representative"))').each(function(){
    var td1 = $(this).children('td:eq(1)');
    td1.html(td1.html().replace(/<a href="http:\/\/www.google.com" target="_blank">([^<]*)<\/a>/i, '$1'));
});

Open in new window

updated fiddle: https://jsfiddle.net/80LfmsLo/1/

Author

Commented:
Great! thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial