Nishima
Nishima

Reputation:

JavaScript removeNode() is not working in Chrome

I need to remove a node from a page, and for that I am using the below mentioned function

document.getElementById(id).removeNode(true);

This function works fine in IE but not in Chrome. Could anyone tell me how should I do it?

Upvotes: 5

Views: 4135

Answers (2)

SharpC
SharpC

Reputation: 7454

The function removeNode() seems to be a Microsoft proprietary function, so probably only supported in Internet Explorer (IE).

Since the latest browsers are typically chromium-based (such as Google Chrome and Microsoft Edge "Wave" v79+) I replaced it with remove() and it seemed to fix the issue:

document.getElementById(id).remove();

Upvotes: 1

Josef Pfleger
Josef Pfleger

Reputation: 74527

You can use removeChild, it works in most browsers.

Upvotes: 3

Related Questions