HTML5 Test Attribute Support


/ Published in: HTML
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.