Answers for "array from nodelist javascript"

4

js convert nodelist to array

// Get all buttons as a NodeList
var btns = document.querySelectorAll('button');

// Convert buttons NodeList to an array
var btnsArr = Array.from(btns);
Posted by: Guest on April-14-2020
0

js array to nodelist

var toNodeList = function(arrayOfNodes){
  var fragment = document.createDocumentFragment();
  arrayOfNodes.forEach(function(item){
    fragment.appendChild(item.cloneNode());
  });
  return fragment.childNodes;
};
Posted by: Guest on August-26-2021

Code answers related to "array from nodelist javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language