I have a script that I’m running and I want to it to select all the ID’s or Class’s instead of just the first one.
<script type = "text/Javascript" >
function color(){
var d=document.getElementsByClassName("black")[0];
d.setAttribute("style", "background-color:#333;");
}
</script>
[0]indocument.getElementsByClassName("black")[0]means that you’re actually discarding all but the first, after selecting them. Use a loop if you want to iterate over the value returned bygEBCN.document.getElementsByTagName('*')if you want all elements.