function next(ele) {
            if (typeof ele.nextElementSibling == 'object') {
                return ele.nextElementSibling;
            }
            var n = ele.nextSibling;
            while (n) {
                if (n.nodeType == 1) {
                    return n;
                }
                n = n.nextSibling;
            }
            return n;
        }

  

nextSibling是获取当前节点的下一个节点。

这个函数第一个检测,ele下一个节点(nextSibling),如果是上元素节点就返回这个,并结束函数,由于html中有空格或者换行符,不一定就是元素节点。则继续循环

nextElementSibling标准浏览器才有这个东西,IE没有,上述方法,是解决兼容性问题

 

相关文章:

  • 2021-07-17
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2022-02-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
相关资源
相似解决方案