I have this table:
<table id="product" class="table table-bordered table-striped">
<thead>
<tr>
<th>Id</th>
<th>Cantidad</th>
<th>Producto</th>
<th>Marca</th>
<th>Precio</th>
<th>Importe</th>
<th>Serial</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
I add rows to that table with this jquery code:
$( "#name" ).autocomplete({
source: 'http://sosacelulares.com/index.php/product/search',
minLength: 1,
select: function (event, ui) {
var value = ui.item.value;
var data1 = value.split("-");
var data = data1[0].split(" ");
$( "#product" ).show();
var v = data[1];
$.ajax({
async:true,
type: "POST",
dataType: "html",
contentType: "application/x-www-form-urlencoded",
url:"http://sosacelulares.com/index.php/product/get",
data:"id="+v,
success: function(response) {
var returnedData = JSON.parse(response);
$("#product > tbody").append('<tr><td>' + returnedData[0].id_product + '</td><td><input min="1" type="number" style="width: 100px;" value="" class="form-control quantity" id="quantity" placeholder="Cantidad" required></td><td>' + returnedData[0].name + '</td><td>' + returnedData[0].brand + '</td><td><input type="text" style="width: 100px;" value="' + returnedData[0].buy_price + '" class="form-control" placeholder="Precio" required></td><td></td><td><a href=""><button type="submit" class="btn btn-success">Agregar Serial</button></a></td></tr>');
}
});
},
});
I just look for a name in a text input and then when I find it I just add it to the table. The problem is that the rows that I am adding they have a number input field that it is to add the quantity I test it like this:
$(".quantity").change(function () {
alert(1);
});
I do not know why if I change the quantity input that it is ubicated within the new row that i added with jquery it does not work, if I make a change the alert does not appear, what am I doing bad? Thanks!