3 ms·
> PS. The other two answers here are outdated. Sure, the other two answers may be "outdated" but they're still extremely useful if you're looking to calling ma
by j79 8y ago
> PS. The other two answers here are outdated.
Sure, the other two answers may be "outdated" but they're still extremely useful if you're looking to calling map/filter/etc against your queried elements.
- runarberg 8y agoFor that you can write: const elements = document.querySelectorAll('.some-class'); const values = Array.prototype.map.call(elements, element => element.value); or more idiomatically (and perhaps a little slower): const elements = [...document.querySelectorAll('.some-class')]; const values = elements.map(element => element.value);
- nailer 8y agoThey asked about looping, not mapping or filtering.