Created
April 22, 2019 10:47
-
-
Save Signifies/62a2fcae4b7346a10433e1b15897047f to your computer and use it in GitHub Desktop.
HTML feature test using pure JS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For this method, it orders the results in a list, however, you can remove that and just test for the conditionals.