document.querySelectorAll get innerText of ALL selected elements at once pure javascript

后端 未结 1 864
梦毁少年i
梦毁少年i 2021-02-04 18:41

I want to get all innerText of a whole column of a very long html table (random length). I\'m using this code:

var tbEls = document.querySelectorAll(\'#tBodyID t         


        
相关标签:
1条回答
  • 2021-02-04 19:42

    The easiest way I found was to convert the nodeList to an array first then use a map:

    var nodes = document.querySelectorAll("h3 em");
    var list = [].slice.call(nodes);
    var innertext = list.map(function(e) { return e.innerText; }).join("\n");
    
    0 讨论(0)
提交回复
热议问题