Created
May 1, 2015 15:48
-
-
Save stepheneyer/659a45627b61c1af240a to your computer and use it in GitHub Desktop.
querySelectorAll with tags/classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener("load", function (){ | |
alert("Loaded!"); | |
//.querySelectorAll - with tags | |
var listItems = document.querySelectorAll ("li"); | |
//Becomes an array-like object, check that contains contents with .length | |
//listItems.length; | |
for (i = 0; i < listItems.length; i++) { | |
listItems[i].style.borderBottom = "2px solid black"; | |
} | |
//.querySelectorAll - with classes | |
var collections = document.querySelectorAll (".datatype"); | |
//collections.length; | |
for (i = 0; i < collections.length; i++) { | |
console.log(collections[i]); | |
collections[i].style.color = "red"; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment