I'm trying to use querySelectorAll () to get each 'td' element in which the alignment attribute is & Amp; The child of 'tr' is
This works:
document.querySelectorAll ('tr & gt; td');
And it works:
document.querySelectorAll ('[align]');
But how to combine them?
Preface: None tr & gt; Point to
td
in front of:. That's why I left it down.
It depends on what you want to do.
-
If you only
align
attribute withtd
element attribute:document. QuerySelectorAll ("td [align]")
-
or only
td
element which aretr
elements whose Close aalign
attributedocument. The class selector is the only element <
td
attribute containing the attribute ("tr [align] gt; td")or
alignment document.querySelectorAll ("td [align]")
- < > Document.querySelectorAll ("td [align]")
... and so on; .
Enter your comment below:
It works, but is there a way to not select TD before every t?
There is nothing about this in your question.
You can use td: not (: nth-child (0))
means "a td
means that the first child of her parents " provided" is not that you have script
code> tr (which is valid, but It's a strange thing.) With that rule, it works, because only td
and scripts
are valid codecs tr
.
Or you just select pants and all relevant td
s and then:
var list = Array.protot Ype.slice.call (document.querySelector ("whatever"), 1);
... the first entry in the list returned by you querySelectorAll
.
Further comment:
tr [style]> gt; td [align]: not (: nth -child (0))
550 node list returned is equal totr [style]> td [align]
right. Again, : nth-child
sees who this child is, no where it comes in the list selected by the previous selector.
If you want to leave td
first in the Each line, and you want to ignore tr
with which is not a style
attribute, it is more complex:
var results = Array.prototype.reduce.call (document.querySelectorAll ("tr [genre]") , Function (list, line) {list.push .color (list, array.propytipicolicycol (line.quiricious all ("tr [align]"), 1)); return list;}, []);
No comments:
Post a Comment