Last active
July 3, 2018 09:54
-
-
Save langjt/b87037f15ae18721734b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getElementsByClassName(clsName, element) { | |
var arr = []; | |
var aEle = element.getElementsByTagName('*'); | |
var re = new RegExp('\\b'+ clsName +'\\b'); | |
for (var i= 0,len=aEle.length; i<len; i++) { | |
if (re.test(aEle[i].className)) { | |
arr.push(aEle[i]); | |
} | |
} | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment