6
Is there any way to "focus" the minutes of a input
of the kind time
?
By default, the focus()
direct to the "hours" that is the beginning of the input
, empty or filled:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
function foco(v) {
if(v == 1) {
$('#hora1').focus();
} else {
$('#hora2').focus();
}
}
</script>
<div class="container">
<div class="row">
<button class="btn btn-primary mr-2" onclick="foco(1)"><b>Foco 1</b></button>
<button class="btn btn-primary" onclick="foco(2)"><b>Foco 2</b></button>
</div>
<br>
<div class="row">
<form id="formX" onsubmit="return false">
<div id="reg" class="form-row">
<div class="form-group mr-2">
<label for="hora1">Hora 1</label>
<input id="hora1" type="time" class="form-control"/>
</div>
<div class="form-group mr-2">
<label for="hora2">Hora 2</label>
<input id="hora2" type="time" class="form-control" value="10:10"/>
</div>
</div>
</form>
</div>
</div>
You will use the hours too, or just minutes?
– hugocsl
I will use the 2... but always focus on the minutes.. let’s assume that there are 4 houses: HH:MM... Focus on the first minute house (input third)
– rbz