javascript - chaining using getElementsByClassName -
<script> var elms = document.getelementbyid("contentwrapper").getelementsbyclassname("pbsubheader brandtertiarybrd tertiarypalette"); console.log(elms); (var i=0; i<elms.length; i++) { console.log(elms[i]); } </script> when try using getelementsbyclassname see no logs related second console.log message. 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 further drill down head_01bd000000wqj9k_ep , firstchild of class pbsubheader brandtertiarybrd tertiarypalette
someone please correct me if not chaining correct. in advance
you can use document.queryselectorall("#contentwrapper .pbsubheader, #contentwrapper .brandtertiarybrd, #contentwrapper .tertiarypalette") aware function isn't supported in ie7 , lower.
Comments
Post a Comment