Skip to content

Instantly share code, notes, and snippets.

@charleshimmer
Created December 23, 2011 16:40
Show Gist options
  • Save charleshimmer/1514696 to your computer and use it in GitHub Desktop.
Save charleshimmer/1514696 to your computer and use it in GitHub Desktop.
Testing autofocus
function featureTest(element, attribute);
var el = document.createElement('input');
if(attribute in el){
return true;
else{
return false;
}
}
// to test if an browser supports the new HTML 5 autofocus attribute you would do this
if( ! featureText('input', 'autofocus')){
// place JavaScript fallback (i.e. polyfill here)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment