javascript forEach for queryselector

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript forEach for queryselector相关的知识,希望对你有一定的参考价值。

// REF: https://css-tricks.com/snippets/javascript/loop-queryselectorall-matches/

let forEach = function (array, callback, scope) {
  for (var i = 0; i < array.length; i++) {
    callback.call(scope, i, array[i])
  }
}

// const myNodeList = document.querySelectorAll('li')
// if(myNodeList.length > 0) {
//  forEach(myNodeList, function (index, value) {
//    console.log(index, value)
//  })
// }

export default forEach

以上是关于javascript forEach for queryselector的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript中for in,for, for of,forEach之间的区别

JavaScript里的循环方法:forEach,for-in,for-of

javascript forEach for queryselector

JavaScript - myArray.forEach 与 for 循环的细微差别

JavaScript - For loop vs forEach

javascript 中forEach,for in循环的用法