Skip to content
Advertisement

Remove links with JavaScript in browser

How do I remove links from a webpage with JavaScript? I am using Google Chrome. The code I tried is:

JavaScript

Of course, this is test code, which is why I have the alerts and 2 things trying at the same time. The first alert returns “0” the second [Object NodeList] and the third returns “done”.

My html body looks like this:

JavaScript

Advertisement

Answer

JavaScript

This works. As I am in control of the content, I named all the anchors “link” using a simple search and replace. If you run it once, it takes out every other one. So I just had it repeat, as you can see, till they are all out.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement