Created
September 5, 2014 01:38
-
-
Save longlho/c46292964421e61f3077 to your computer and use it in GitHub Desktop.
getElementsByClassName Polyfill for IE8
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 () { | |
if (!document.getElementsByClassName) { | |
window.Element.prototype.getElementsByClassName = document.constructor.prototype.getElementsByClassName = function (classNames) { | |
classNames || (classNames = '*'); | |
classNames = classNames.split(' ').join('.'); | |
if (classNames !== '*') { | |
classNames = '.' + classNames; | |
} | |
return this.querySelectorAll(classNames); | |
}; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment