I am drawing an input dynamically in a table with
document.getElementById('agregaDevolucion').innerHTML =
"Devolución:<input type='text' name='txtDeposito' id='txtDeposito'/>";
and that same input searches a BD through AJAX
with the event focusout
of the input, with the following code
$('#txtDeposito').focusout(function(){
this.value = this.value.toUpperCase();
var solicitud = $('#idce').val();
var devolucion = $('#txtDeposito').val();
alert(devolucion);
$.post("buscaSolicitud.asp", { solicitud : solicitud, devolucion : devolucion},
function (data, textStatus, jqXHR) {
console.log(data);
var cadena = data.toString();
console.log(data);
if(cadena=="OK"){
$('#btnEnvia').show();
$('#error').text("Correcto").css({"color":"green"});;
}else{
$('#btnEnvia').hide();
$('#error').text("El número de devolución no coincide con la solicitud").css({"color":"red"});
}
});
});
But the problem I have is that the input I draw does not throw the event focusout
since when testing my application it does nothing, before making dynamic the input was static and if it worked, I do not understand why it does not do anything