elements


document.querySelectorAll get innerText of ALL selected elements at once pure javascript


I want to get all innerText of a whole column of a very long html table (random length).
I'm using this code:
var tbEls = document.querySelectorAll('#tBodyID tr td:nth-child(cidx)');
Where cidx = the column index I want to extract content from.
But such code extracts all the td elements (with the innerText inside them of course).
But it doesn't extract directly all the innerText inside them. Cause of this I have to reprocess the returned tdEls array with a for loop to extract from each tbEls[i] element its own innerText. It works but...
My question is:
In pure JS (no external libraries or frameworks) is it possible to use a more direct approach improving some way just and only the querySelectorAll parameter ('#tBodyID tr td:nth-child(cidx)') to get directly all the td elements innerText at once and in just one javascript statement and without the need of reprocessing the returned array with the for loop or anything else?
In other words is there a some kind of innerText selector that can be used to get them all at once without any kind of extra loop?
No problem at all if it is not recognized by old browsers, I'm sorry for them.
What I hope to achieve is something like:
var arrTblColInnerText = document.querySelectorAll('#tBodyID tr td:nth-child(cidx):alltd:innerText');
I want to get an array similar to:
0: value from column cidx cell 0
1: value from column cidx cell 1
2: value from column cidx cell 2
3: value from column cidx cell 3
...
n: value from column cidx cell n
Thanks in advance.
The easiest way I found was to convert the nodeList to an array first then use a map:
var nodes = document.querySelectorAll("h3 em");
var list = [].slice.call(nodes);
var innertext = list.map(function(e) { return e.innerText; }).join("\n");

Related Links

document.querySelectorAll get innerText of ALL selected elements at once pure javascript
locating submit element that is dynamically changing
Why suddenly some things have disappeared from the body section?
JavaFX 2.0 resizing everything on scene
MAking an element hidden in XSL FO

Categories

HOME
ionic-framework
jdo
activiti
fluentd
routes
rsync
youtube-api-v3
installshield
ravendb
fancybox
datastax-java-driver
azure-media-services
node-notifier
vifm
modx-revolution
spring-tool-suite
vb.net-2010
moonmail
gz
seaborn
after-effects
aurigma
predix
tokenize
sylius
blazemeter
p-value
fish
virtualdub
uninstall
phpfox
filezilla
publish
neo4j-spatial
facebook-apps
preg-match
phonegap
functor
oracle-fusion-middleware
ioio
copying
form-data
accelerate-framework
wallpaper
cloud-code
catalog
bytecode-manipulation
simplexml
x11-forwarding
bootstrapper
email-templates
mime
prolog-setof
dropbox-php
lowpass-filter
carrot
spring-mongodb
spring-cache
messenger
watchconnectivity
fody
nsfilemanager
bstr
superstack
packagist
hexdump
freedesktop.org
iad
purge
content-length
quicklisp
sframe
event-bubbling
clicktag
network-interface
javafx-webengine
openexr
typeof
starcluster
uitouch
kgdb
datagridviewcolumn
transcoding
typo3-neos
page-layout
html4
plasma
orchardcms-1.7
runas
datawindow
javaspaces
gnustep
netbeans-7.1
file-comparison
pyinotify
floating
remember-me
sudzc
createwindow
.nettiers
mozilla-prism
jquery-ui-droppable
thunderbird-lightning
brewmp
port-number
mediarss
msdev
lzh

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App