2
我正在嘗試<td>
內的警報值。從輸入文本中獲取值然後提醒它
$(document).ready(function() {
$('.edits').each(function(index) {
$(this).change(function() {
alert($(this).val());
});
});
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<table width="200" border="1">
<tbody>
<tr>
<td width="40">2</td>
<td width="144">
<input class="edits" type="text">
</td>
</tr>
<tr>
<td>3</td>
<td>
<input class="edits" type="text">
</td>
</tr>
<tr>
<td>5</td>
<td>
<input class="edits" type="text">
</td>
</tr>
</tbody>
</table>
確定。從上面現在我能夠alert
它。但是如果從append
呢?如何提醒它?
function generateDetail(){
var nilai = $("#poTrans").val();
$.ajax({
url: '<?=base_url();?>bapb_mutasi/background_list_fa_detail/' + nilai,
dataType: 'JSON',
success: function(data) {
$.each(data, function(k, v) {
$("#result").append('<tr>' +
'<td> </td> ' +
'<td> '+v.TransactionNo+' </td>'+
'<td> '+v.LineNo+' </td>'+
'<td> '+v.ItemCode+' </td>'+
'<td> '+v.ItemName+' </td>'+
'<td> '+v.Quantity+' </td>'+
'<td> '+v.UOMCode+' </td>'+
'<td> '+v.QuantityConvertingRatio+' </td>'+
'<td class="base"> '+parseInt(v.BaseQuantity)+' </td>'+
'<td> '+parseInt(v.QuantityReceived)+' </td>'+
'<td class="edittbl">' +
'<input class="edits" type = "text" name = "quantityEdit"> </td>'+
'<td> '+v.BaseUOMCode+' </td>'+
'<td> '+v.ExtraRemark+' </td>'+
'<td> '+v.ExtraRemark2+' </td>'+
'</tr>'
);
$('.edits').val(v.QuantityEdit);
});
}
});
}
這裏是我的HTML表格
<table width="631" id="bla" class="table table-bordered">
<thead>
<tr>
<td><strong> Document No </strong></td>
<td><strong> Transaction No </strong></td>
<td><strong> Line No </strong></td>
<td><strong> Item Code </strong></td>
<td><strong> Item Name </strong></td>
<td><strong> Quantity </strong></td>
<td><strong> UOM Code </strong></td>
<td><strong> Quantity Converting Ration </strong></td>
<td><strong> Base Quantity </strong></td>
<td><strong> Quantity Received </strong></td>
<td><strong> Quantity Edit </strong></td>
<td><strong> Base UOM Code </strong></td>
<td><strong> Extra Remark </strong></td>
<td><strong> Extra Remark 2 </strong></td>
</tr>
</thead>
<tbody id="result">
</tbody>
</table>
結果例
[{"DocumentNo":"","TransactionNo":"LPOD-CJ-AR1-1983","LineNo":1000,"ItemCode":"J101260012","ItemName":"DISPLAY RACK","Quantity":"6.00000000000000000000","UOMCode":"PCS","QuantityConvertingRatio":1,"BaseQuantity":"6.00000000000000000000","QuantityReceived":0,"QuantityEdit":"6.00000000000000000000","BaseUOMCode":"PCS","ExtraRemark":"","ExtraRemark2":"","UnitCost":"31999.99999999999600000000","UnitCostAfterPayable":"31999.99999999999600000000","BaseUnitCost":"31999.99999999999600000000","BaseUnitCostAfterPayable":"31999.99999999999600000000"," ":""},{"DocumentNo":"","TransactionNo":"LPOD-CJ-AR1-1984","LineNo":2000,"ItemCode":"URS150400001","ItemName":"RAISER","Quantity":"2.00000000000000000000","UOMCode":"PCS","QuantityConvertingRatio":1,"BaseQuantity":"2.00000000000000000000","QuantityReceived":0,"QuantityEdit":"2.00000000000000000000","BaseUOMCode":"PCS","ExtraRemark":"","ExtraRemark2":"","UnitCost":"88000.00000000000000000000","UnitCostAfterPayable":"88000.00000000000000000000","BaseUnitCost":"88000.00000000000000000000","BaseUnitCostAfterPayable":"88000.00000000000000000000"," ":""}]
我Problemm只有當我試圖提醒我輸入在這裏(從appends
)
<input class="edits" type = "text" name = "quantityEdit">
對不起,我的英語不好。
謝謝,你讓我很快樂 – YVS1102
對不起,你能告訴我,我怎麼可以用'類匹配它='base'' – YVS1102
@ YVS1102樂意幫忙。這個班在哪裏?哪個元素? – ScanQR