for of loop querySelectorAll

前端 未结 9 827
忘了有多久
忘了有多久 2020-12-11 02:29

Mozilla states that \"for of loops will loop over NodeList objects correctly\". (source: https://developer.mozilla.org/en-US/docs/Web/API/NodeList) However, this doesn\'t wo

9条回答
  •  一生所求
    2020-12-11 02:50

    Since I've successfully used for..of in Gecko to iterate NodeLists, it seems this is a browser bug, or at least a browser lack.

    Actual working code from a userscript I currently use:

    let llnk = document.querySelectorAll("div#threadlist a.threadtitle_unread");
    for (let lnk of llnk) {
        //...
    }
    

    (This also uses let, but that's another story.)

提交回复
热议问题