この方法IEは `HTMLElement.remove`をサポートしていません。

IEの心にピットを埋め

  1. 使ってもいいですか
  2. MDN子ノードを削除します
  3. StackOverflowのjavascriptの-削除-doesntの仕事・イン・すなわち

PolyfillSection

あなたは、Internet Explorer 9と次のコードで上位にremove()メソッドをポリフィルことができます。

// from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md
(function (arr) {
  arr.forEach(function (item) {
    if (item.hasOwnProperty('remove')) {
      return;
    }
    Object.defineProperty(item, 'remove', {
      configurable: true,
      enumerable: true,
      writable: true,
      value: function remove() {
        if (this.parentNode === null) {
          return;
        }
        this.parentNode.removeChild(this);
      }
    });
  });
})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);

おすすめ

転載: www.cnblogs.com/givingwu/p/11302280.html