Skip to content

Instantly share code, notes, and snippets.

@jackfranklin
Created August 20, 2011 12:58
Show Gist options
  • Save jackfranklin/1159075 to your computer and use it in GitHub Desktop.
Save jackfranklin/1159075 to your computer and use it in GitHub Desktop.
Check for attribute support with JS
function checkAttribute(element, attribute) {
var test = document.createElement(element);
if (attribute in test) {
return true;
} else {
return false;
}
}
checkAttribute("input", "required");
//or a tidier version
function checkAttribute(elem, attr) {
return attr in document.createElement(elem);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment