Full version: jsB@nk » » All Elements By Class Finder
URL: https://www.javascriptbank.com/all-elements-by-class-finder.html
This function script will return an array of tags based on DOM element, tag, and class name. For example, getElementsByClassName(document, 'tr', 'info')
will return to you an array of all "tr
" tags under the document node having the "info
" class.
Full version: jsB@nk » » All Elements By Class Finder
URL: https://www.javascriptbank.com/all-elements-by-class-finder.html
<script type="text/javascript">// Created by: Joe Homs | http://bitshaker.com/function getElementsByClassName(oElm, strTagName, strClassName){ var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName); var arrReturnElements = new Array(); strClassName = strClassName.replace(/-/g, "\-"); var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)"); var oElement; for(var i=0; i<arrElements.length; i++){ oElement = arrElements[i]; if(oRegExp.test(oElement.className)){ arrReturnElements.push(oElement); } } return (arrReturnElements)}</script>