Doing an alert() on one of my variables gives me this result
[object NodeList]
How can I see all the values in that?
Note; I am on Firefox and dont know how to use chromebug so its not installed.
Jump to: NodeList objects are collections of nodes, usually returned by properties such as Node.childNodes and methods such as document.querySelectorAll(). Although NodeList is not an Array, it is possible to iterate over it with forEach().
The NodeList.values () method returns an iterator allowing to go through all values contained in this object. The values are Node objects. Returns an iterator. The compatibility table on this page is generated from structured data.
NodeList items can only be accessed by their index number. Only the NodeList object can contain attribute nodes and text nodes. A node list is not an array! A node list may look like an array, but it is not. You can loop through the node list and refer to its nodes like an array.
Returns an item in the list by its index, or null if the index is out-of-bounds. An alternative to accessing nodeList [i] (which instead returns undefined when i is out-of-bounds). This is mostly useful for non-JavaScript DOM implementations. Returns an iterator, allowing code to go through all key/value pairs contained in the collection.
You can iterate the values in a NodeList
the same way you would an array:
for (var index = 0; index < nodeList.length; index++) {
alert(nodeList[index]);
}
Here is a good resource with some more in-depth information: https://web.archive.org/web/20170119045716/http://reference.sitepoint.com/javascript/NodeList
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With