In es6 you can just use as follows:
-
Spread operator
var elements = [... nodelist]
-
Using
Array.from
var elements = Array.from(nodelist)
more reference at https://developer.mozilla.org/en-US/docs/Web/API/NodeList
More Related Contents:
- Trying to use Javascript to add new li element to my ordered list, anyone know why this code isn’t working?
- Do DOM tree elements with IDs become global properties?
- How to make JavaScript execute after page load?
- Changing website favicon dynamically
- How do I programmatically set the value of a select box element using JavaScript?
- Dynamically set value of a file input [duplicate]
- How to correctly iterate through getElementsByClassName
- Appending HTML string to the DOM
- How to append text to a “?
- Best Practice: Access form elements by HTML id or name attribute?
- Difference between Node object and Element object?
- Why are duplicate ID values not allowed in HTML?
- HTML “overlay” which allows clicks to fall through to elements behind it [duplicate]
- JavaScript get element by name
- Is there a DOM event that fires when an HTML select element is closed?
- Difference between Element.value and Element.getAttribute(“value”)
- Why is the variable holding the input value always logged as empty?
- HTML DOM: Which events do not bubble?
- How do I put codes from jsfiddle.net into my website?
- Focus Input Box On Load
- Screen Scraping from a web page with a lot of Javascript [closed]
- Attach event listener through javascript to radio button
- window.getSelection() gives me the selected text, but I want the HTML
- Is there a flexible way to modify the contents of an editable element?
- a way to check validity of HTML5 forms?
- Open new window without focus on it [duplicate]
- Is there a way to get innerText of only the top element (and ignore the child element’s innerText)?
- window.getSelection return html [duplicate]
- Images failing to load in IE with DOM: 7009 error (unable to decode) in console
- Why is iframe.contentWindow == null?