I was looking at some snippets of code, and I found multiple elements calling a function over a node list with a forEach applied to an empty array. For example I have something like: [].forEach.call( document.querySelectorAll('a'), functi...
After providing an incorrect answer concerning the .item() property of Node.childNodes for a question, I inspected __proto__ of the returned childNodes of a form element and found a forEach method. The forEach method of Node.childNodes is not docu...
In ES6, an iterable is an object that allows for... of, and has a Symbol.iterator key. Arrays are iterables, as are Sets and Maps. The question is: are HTMLCollection and NodeList iterables? Are they supposed to be? MDN documentation seems to sugg...
Traditionally, a suggested way of removing a node's children in Javascript is to do something like this: while(node.firstChild) { node.removeChild(node.firstChild); } Recently, I attempted to remove all of a node's children using the b...
I'm trying to get a list in JavaScript (not using jQuery) of all the elements on the page with a specific class name. I therefore employ the getElementsByClassName() function as follows: var expand_buttons = document.getElementsByClassName('...
I am trying to display data from an external .jsp file, which is set up something like this: <tag> <innertag1 id="1"> <innertag1 id="2"> </tag> <tag> <innertag2 id="3"> <innertag...
Why don't getElementsByName, getElementsByTagName, and getElementsByClassName return an HTMLCollection (W3C, MDN) instead of a NodeList (W3C, MDN)? All three return a live NodeList of only elements: document.getElementsByName('nameAttrVal...
I am using a forEach to loop through a nodeList. My code is as follows var array = document.querySelectorAll('items'); array.forEach(function (item) { console.log(item); }); And this code throws an error as Uncaught TypeError: a...
I have what I think should be a straightforward question; let me quickly explain: In my JavaScript, food.xml is read in with: getMenuXml.open("GET","food.xml",false); getMenuXml.send(); xmlDoc=getMenuXml.responseXML; xmlFoodList = x...
This question already has answers here:...
©2020 All rights reserved.