首页 > Web开发 > 详细

IE 不支持 `HTMLElement.remove` 方法

时间:2019-08-05 12:58:12      阅读:132      评论:0      收藏:0      [点我收藏+]

IE 填坑记

  1. Can i use
  2. MDN ChildNode remove
  3. StackOverflow javascript-remove-doesnt-work-in-ie

技术分享图片

PolyfillSection

You can polyfill the remove() method in Internet Explorer 9 and higher with the following code:

// 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]);

IE 不支持 `HTMLElement.remove` 方法

原文:https://www.cnblogs.com/givingwu/p/11302280.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!