Skip to content

Instantly share code, notes, and snippets.

@joshje
Created August 16, 2011 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshje/1149224 to your computer and use it in GitHub Desktop.
Save joshje/1149224 to your computer and use it in GitHub Desktop.
Cross Browser CSS Selector Support Detection
function supports(prop) {
var div = document.createElement('div'),
vendors = ['Khtml','Ms','O','Moz','Webkit'],
len = vendors.length;
if (prop in div.style) return true;
var prop = prop.replace(/^[a-z]/, function(val) {
return val.toUpperCase();
});
while(len--) {
if ( vendors[len] + prop in div.style ) return true;
}
return false;
}
// Usage (JS styles are camelCase):
// document.getElementsByTagName('html')[0].className += supports('transitionProperty')? ' transitions' : ' no-transitions';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment