Object doesn't support property or method 'remove'

remove() as a method on HTMLElements unfortunately is not supported by Internet Explorer.

You could use the workaround in this SO answer for a vanilla javascript solution.

However as you already seem to use jQuery, instead replace

document.getElementById('tab-' + x).remove();

with

$('#tab-' + x).remove();

You should get the parent of the element you are trying to remove and use the remove child method to find and remove the element

element.parentNode.removeChild(element);

this works in all browsers including IE.


You should use this

element.parentElement.removeChild(element);

Supported by all browser and also have some benefits over just a hack to remove child element.

Here is another workaround for keep using .remove() function

Element.prototype.remove = function() {
    this.parentElement.removeChild(this);
}
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
    for(var i = this.length - 1; i >= 0; i--) {
        if(this[i] && this[i].parentElement) {
            this[i].parentElement.removeChild(this[i]);
        }
    }
}

And then you can remove elements like this

document.getElementById("my-element").remove();

or

document.getElementsByClassName("my-elements").remove();

Here is Stack Overflow link for further info also source of this answer.