Created
July 6, 2015 23:42
-
-
Save edirpedro/cf7ebbbf736d95af1d4d to your computer and use it in GitHub Desktop.
Check support for a CSS property
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 hasCSS(name) { | |
// Checking an array | |
if (typeof name == 'object') { | |
for (var n in name) { | |
if (hasCSS(name[n]) === false) | |
return false; | |
} | |
return true; | |
} | |
// Checking a single name | |
var e = document.createElement('div').style; | |
var prefixes = ['-ms-','-o-','-moz-','-webkit-']; | |
if (e[name] == '') return true; | |
for (var i in prefixes) { | |
var prop = prefixes[i] + name; | |
if (e[prop] == '') | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment