Skip to content

Instantly share code, notes, and snippets.

@Signifies
Created April 22, 2019 10:47
Show Gist options
  • Save Signifies/62a2fcae4b7346a10433e1b15897047f to your computer and use it in GitHub Desktop.
Save Signifies/62a2fcae4b7346a10433e1b15897047f to your computer and use it in GitHub Desktop.
HTML feature test using pure JS.
function featureTest() {
document.getElementById("heading").innerHTML = "Compatible HTML5 Features";
var typeValues = ["search", "number", "range", "color", "tel", "url", "email", "date", "month", "week", "datetime", "datetime-local"];
var i = document.createElement("input");
var dataValues = "";
dataValues += "<ul>";
for(l=0; l <= typeValues.length; l++) {
i.setAttribute("type",typeValues[l]);
var result = i.type !== "text" ? "YES" : "NO";
dataValues += "<li>" + typeValues[l] + ": " + result+"</li>";
}
dataValues +="</ul>";
document.getElementById("output").innerHTML = dataValues;
}
@Signifies
Copy link
Author

For this method, it orders the results in a list, however, you can remove that and just test for the conditionals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment