Javascript building element reference node list

前端 未结 1 596
隐瞒了意图╮
隐瞒了意图╮ 2021-01-22 10:39

How can i build a nodelist, which is reference to the selected node? Example document.querySelectorAll(\'tr\') returns a nodelist contains all the tr element no

相关标签:
1条回答
  • 2021-01-22 11:24

    If you don't want to move things around in the DOM, don't use the methods that move things around!

    var nl = new Array();
    var el = document.querySelectorAll('tr');
    for ( var a = 0; a < 2 && a < el.length; a++)
    {
        nl.push(el[a]);
    }
    
    0 讨论(0)
提交回复
热议问题