/ Published in: Other
Expand |
Embed | Plain Text
document.getElementsByClassName = function(searchClass, node, tag){ var classElements = []; node = node || document; var pattern = new RegExp('(^|\\s)' + searchClass+ '(\\s|$)'); var els = (!tag && node.all) || node.getElementsByTagName(tag || '*'); var elsLen = els.length; for (var i=0, j=0;i<els.length;i++) { if (pattern.test(els[i].className)) { classElements[j] = els[i]; j++; } } return classElements; }
Comments
Subscribe to comments
You need to login to post a comment.

Interesting how you and Dustin Diaz made the exact same function, isn't it? http://www.dustindiaz.com/getelementsbyclass/
is this more powerful than the $() function offered by libraries