improved, possibly faster getelementsbyclass by willu
parent
3640b88f95
commit
89e0de5bc4
|
@ -39,18 +39,22 @@ function toggle(s) {
|
||||||
style.display = "none";
|
style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getElementsByClass(c) {
|
function getElementsByClass(cls, node, tag) {
|
||||||
|
if (document.getElementsByClass)
|
||||||
|
return document.getElementsByClass(cls, node, tag);
|
||||||
|
if (! node) node = document;
|
||||||
|
if (! tag) tag = '*';
|
||||||
var ret = new Array();
|
var ret = new Array();
|
||||||
var pattern = new RegExp("(^|\\s)"+c+"(\\s|$)");
|
var pattern = new RegExp("(^|\\s)"+cls+"(\\s|$)");
|
||||||
var els = document.getElementsByTagName('*');
|
var els = node.getElementsByTagName(tag);
|
||||||
for (i = 0, j = 0; i < els.length; i++) {
|
for (i = 0; i < els.length; i++) {
|
||||||
if ( pattern.test(els[i].className) ) {
|
if ( pattern.test(els[i].className) ) {
|
||||||
ret[j] = els[i];
|
ret.push(els[i]);
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-->
|
//-->
|
||||||
</script>
|
</script>
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -53,3 +53,6 @@ Looking at the Safari Web Inspector, it believes there is a parse error on line
|
||||||
>> they're filled in with useful defaults.
|
>> they're filled in with useful defaults.
|
||||||
|
|
||||||
>> I don't know if it is worth making this change, but it is there if you want it.
|
>> I don't know if it is worth making this change, but it is there if you want it.
|
||||||
|
|
||||||
|
>>> Well, it seems to work. Although god only knows about IE. Suppose I
|
||||||
|
>>> might as well.. --[[Joey]]
|
||||||
|
|
Loading…
Reference in New Issue