The focus()
method sets focus to a time field.
The focus()
method is supported in all major browsers.
focus |
Yes | Yes | Yes | Yes | Yes |
timeObject.focus()
None.
No return value
The following code shows how to set focus to a time field.
<!DOCTYPE html>
<html>
<body>
<!--from w w w . jav a2 s . co m-->
<input type="time" id="myTime" value="22:15:00">
<button type="button" onclick="getFocus()">Get focus</button>
<button type="button" onclick="loseFocus()">Lose focus</button>
<script>
function getFocus() {
document.getElementById("myTime").focus();
}
function loseFocus() {
document.getElementById("myTime").blur();
}
</script>
</body>
</html>
The code above is rendered as follows: