Posted By

vagrantradio on 08/13/10


Tagged

html5


Versions (?)

HTML5 Test Attribute Support


 / Published in: HTML
 

Generic function to test whether and element supports a particular element in HTML5.

  1. function checkAttribute(element, attribute) {
  2. var test = document.createElement(element);
  3. if (attribute in test) {
  4. return true;
  5. } else {
  6. return false;
  7. }
  8. }
  9.  
  10. //usage
  11. if (!checkAttribute('input', 'placeholder')) {
  12.  
  13. }

Report this snippet  

You need to login to post a comment.