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
date
keras
zeromq
image-processing
plot
bpmn
ckeditor
baqend
ravendb
podio
maude-system
spring-xd
modelica
jplayer
graphlab
fatal-error
google-static-maps
karma-jasmine
autocad-plugin
zapier
bootstrap-tour
jndi
intel-pin
info.plist
typo3-6.2.x
kendo-datasource
google-rich-snippets
key-value-observing
ghost4j
mmenu
file-format
ruby-on-rails-3.1
keydown
rails-routing
pnotify
datastax-startup
rdfs
colorama
magma
ableton-live
color-picker
passport-google-oauth
multi-level
storekit
markojs
bgp
pyke
netmq
wordml
rgeo
angular-leaflet-directive
drawbitmap
dundas
formatjs
client-side-templating
websocket4net
googlemock
ccss
runtime.exec
batterylevel
jquery-mobile-dialog
random-seed
limejs
sublist
broken-links
runas
newtonscript
infobox
self-extracting
mongomapper
getresponsestream
user-friendly
privilege
defensive-programming
mdac
document-conversion

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App