'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?



Solution 1:[1]

You can use removeChild, it works in most browsers.

Solution 2:[2]

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();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Josef Pfleger
Solution 2 SharpC