Skip to content

Instantly share code, notes, and snippets.

@tamebadger
Last active December 31, 2015 03:19
Show Gist options
  • Save tamebadger/7927230 to your computer and use it in GitHub Desktop.
Save tamebadger/7927230 to your computer and use it in GitHub Desktop.
document.getElementsByAttribute = Element.prototype.getElementsByAttribute = function(attr) {
var nodeList = this.getElementsByTagName('*');
var nodeArray = [];
for (var i = 0, elem; elem = nodeList[i]; i++) {
if ( elem.getAttribute(attr) ) nodeArray.push(elem);
}
return nodeArray;
};
@tamebadger
Copy link
Author

@tamebadger
Copy link
Author

But the following is preferred for browsers that support it
document.querySelectorAll('a[href$=".mp3"]');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment