Remove specific HTML tag with its content from javascript string

Viewed 18994

I have the following string variable and I want to remove all a tags with its content from the string.

var myString = "<table><tr><td>Some text ...<a href='#'>label...</a></td></tr></table>";
myString += "<table><tr><td>Some text ...<a href='#'>label...</a></td></tr></table>";
myString += "<table><tr><td>Some text ...<a href='#'>label...</a></td></tr></table>";

I have checked this Remove HTML content groups from start to end of string in JavaScript question's answers but it is for all tags.

Thank you

3 Answers
Related