/* * 取得对应类和标签的HTML元素 * clsName:给定类名 * tagName:给定的HTML元素,如果为任意 tagName='*' * */
function getElementsByClassName(clsName, tagName) {
var ClassElements = [];
selElements = document.getElementsByTagName(tagName);
for (var i = 0; i < selElements.length; i++) {
if (selElements[i].className == clsName) {
ClassElements[ClassElements.length] = selElements[i];
}
}
return ClassElements;
}