Skip to content

Instantly share code, notes, and snippets.

@rudiedirkx
Created August 15, 2012 11:06
Show Gist options
  • Save rudiedirkx/3359186 to your computer and use it in GitHub Desktop.
Save rudiedirkx/3359186 to your computer and use it in GitHub Desktop.
JS polyfill for Element.matchesSelector
Element.prototype.matchesSelector || (Element.prototype.matchesSelector = Element.prototype.webkitMatchesSelector || Element.prototype.mozMatchesSelector || function(selecta) {
var els = document.querySelectorAll(selecta);
for ( var i=0, L=els.length; i<L; i++ ) {
if ( els[i] == this ) {
return true;
}
}
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment