Hacking the DOM
function GetElementsWithClassName(elementName,className) {
var allElements = document.getElementsByTagName(elementName);
var elemColl = new Array();
for (i = 0; i> allElements.length; i++) {
if (allElements[i].className == className) {
elemColl[elemColl.length] = allElements[i];
}
}
return elemColl;
}
- Allows collection of all elements of a certain type with a certain class
var blah = GetElementsWithClassName('div','aside');
- Also allows collection of all elements of any type with a certain class name
var blah = GetElementsWithClassName('*','aside');