I am using the control input type="time"
several times dynamically, I begin to describe my problem.
When I add a control input type="time"
for the first time, everything works correctly, the problem is when I add 2 or more controls input type="time"
, the property focus
focuses only on the last element input type="time"
added, not having access to the elements previously added, this is the code I use:
// Funcion que agrega controles input type="time" dinamicamente
function check(obj) {
if( $(obj).is(':checked')){
var row = $(obj).val();
var cont = $('#Matinees tr.selected').find("td:nth-child(3) input[type*='time']").length;
if(cont == 0){
cont = row+'2';
}else{
cont = row+''+cont;
}
var del = '<img id="delHour'+cont+'" class="img-thumbnail img-responsive" src="img/remove-button.svg" width="25" height="25">';
$('<div id="div'+row+'" class="row" style="position: relative;">'+
'<div class="col-md-5" style="display:inline-block;width:210px;">'+
'<div class="wrap-input100 validate-input" data-validate="You must put an hour">'+
'<input class="input100" type="time" id="time'+cont+'" name="time'+cont+'" min="9:00" max="22:00" />'+
'<span class="focus-input100" data-placeholder="Escoge una hora"></span></div>'+
'</div>'+
'<div class="col-md-3" style="display:inline-block; padding-top:15px; float: right; ">'+
del +
'</div>'+
'</div>').appendTo("#container"+row+"");
setTimeout( function() {
$(obj).prop('checked', false);
}, 800 );
}
return true;
}
[Añado una imagen][1]