Is there a way in HTML, javascript, or Razor to detect if the browser supports <input type="time" />
elements?
Thanks in advance.
Invalid values will be rejected when assigned to the .type
property of an input
element.
try {
var input = document.createElement("input");
input.type = "time";
if (input.type === "time") {
console.log("supported");
} else {
console.log("not supported");
}
} catch(e) {
console.log("not supported");
}
If there's some browser issue I'm not aware of, then using .innerHTML
should do the same.
var div = document.createElement("div");
div.innerHTML = "<input type='time'>";
if (div.firstChild.type === "time")
console.log("supported");
else
console.log("not supported");
I think your best option would be to check the browser support and code the usage programmatically.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.