0
我有這個表:數字輸入和jQuery
<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>
我行添加到該表與此jQuery代碼:
$("#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>');
}
});
},
});
我只是尋找一個名字在文本輸入,然後當我發現它只是將它添加到表格中。 的問題是,我加入他們有一些輸入字段,它是添加量行我測試它像這樣:
$(".quantity").change(function() {
alert(1);
});
我不知道爲什麼,如果我改變量輸入那它是在新行內,我用jquery添加它是行不通的,如果我改變警報不出現,我做什麼壞?謝謝!
使用'.on'功能。 '(「。quantity」)。on('change',function(){});' –