//获取某元素后相邻的所有class名为MsoToc2的兄弟元素
nextAll(node){ let that
= this, nextNode = that.next(node), nodeArray = []; while(nextNode != null && that.hasClass(nextNode,'MsoToc2')){ nodeArray.push(nextNode); nextNode = that.next(nextNode); } return nodeArray; }
如:
this.nextAll(msoToc1[i])获取元素msoToc1[i]后边相邻的所有class名为MsoToc2的元素


    //下一个兄弟节点
    next = (node) => {
        let next = node.nextSibling;
        if(next !== null && next.nodeType === 3 ){ //防止内联元素在ie下出现的空白节点和火狐下的空白节点
            return next.nextSibling;
        }
        return next;
    }
    hasClass = (element, cName) => {
        let reg = new RegExp("(?:^| +)" + cName + "(?: +|$)", "g");
        return reg.test(element.className);
    }

 

相关文章:

  • 2021-09-29
  • 2021-10-19
  • 2021-11-24
  • 2021-09-07
  • 2021-11-02
猜你喜欢
  • 2021-09-17
  • 2021-11-25
  • 2022-12-23
  • 2021-09-17
  • 2021-09-17
  • 2022-12-23
相关资源
相似解决方案