getElementsByClassName
function getElementsByClassName(classname) {
var elements;
var pattern;
var i;
var results = [];
if (doc.querySelectorAll) { // IE8
return doc.querySelectorAll('.' + classname);
}
if (doc.evaluate) { // IE6, IE7
pattern = './/*[contains(concat(" ", @class, " "), " " + classname + " ")]';
elements = doc.evaluate(pattern, d, null, 0, null);
while ((i = elements.iterateNext())) {
results.push(i);
}
} else {
elements = doc.getElementsByTagName('*');
pattern = new RegExp('(^|\\s)' + classname + '(\\s|$)');
for (var i = 0, length = elements.length; i < length; i++) {
if (pattern.test(elements[i].className)) {
results.push(elements[i]);
}
}
}
return results;
}
机器瞎学/数据掩埋/模式混淆/人工智障/深度遗忘/神经掉线/计算机幻觉/专注单身二十五年