Reputation: 216
<script>
var elms = document.getElementById("contentWrapper").getElementsByClassName("pbSubheader brandTertiaryBrd tertiaryPalette");
console.log(elms);
for (var i=0; i<elms.length; i++) {
console.log(elms[i]);
}
</script>
When I try using getElementsByClassName I see no logs related to the second console.log message. The first console.log gives me
[item: function, namedItem: function] 0: div#head_01Bd000000WqJ9k_ep.pbSubheader.brandTertiaryBrd.tertiaryPalette head_01Bd000000WqJ9k_ep: div#head_01Bd000000WqJ9k_ep.pbSubheader.brandTertiaryBrd.tertiaryPalette length: 1 proto: HTMLCollection
how to I further drill down into the head_01Bd000000WqJ9k_ep and get the firstchild of the class pbSubheader brandTertiaryBrd tertiaryPalette
Someone please correct me if I am not chaining this correct. Thanks in advance
Upvotes: 0
Views: 1192
Reputation: 3783
You can use document.querySelectorAll("#contentWrapper .pbSubheader, #contentWrapper .brandTertiaryBrd, #contentWrapper .tertiaryPalette")
but be aware that this function isn't supported in IE7 and lower.
Upvotes: 4
Reputation: 543
You can't use getElementsByClassName("pbSubheader brandTertiaryBrd tertiaryPalette");
You can specify only one class, like this:
getElementsByClassName("pbSubheader");
Upvotes: 0