我的查询非常简单,当两个像元值与给定值匹配时,我只是想要像元的值。我已经尽力而不幸。 jQuery tr:contain中是否存在And Logic? 以下是我的Jquery代码
function addItem(val, name, price) {
var qty = parseFloat($('#tablefinaldata tr > th:contains('+val+') + th:contains("N")').find("#itemqty").html());
var UnitPrice = parseFloat($('#tablefinaldata tr:contains(' + val + ')').find("#itemprice").html());
if ($('#tablefinaldata th:contains(' + val + ')').length && $('#tablefinaldata th:contains("N")').length ) {
//alert(qty);
var addqty = qty + 1;
$('#tablefinaldata tr > th:contains(' + val + ') + th:contains("N")').find("#itemqty").html(addqty);
PriceSum(UnitPrice, addqty, val);
CalSum();
}
else {
var table2 = $("#setfinaldata");
table2.empty();
var Newdata = "<tr>" +
"<th id='code'>" + val + "</th>" +
"<th>" + name + "</th>" +
"<th id='itemprice'>" + price + "</th>"
+ "<th style='display:none' id='itemstatus'>N</th>"
+ "<th id='itemqty'>0</th>"
+ "<th id='subtotal'></th>"
+ "</tr>";
$("#tablefinalbody").append(Newdata);
}
}
这是我的表格的html代码
<table class="table table-responsive table-hover table-bordered" id="tablefinaldata" style="font-family:Arial;font-weight:300">
<thead>
<tr>
<td>
<h5> Code</h5>
</td>
<td>
<h5> Item</h5>
</td>
<td>
<h5> Price</h5>
</td>
<td>
<h5> Quantity</h5>
</td>
<td>
<h5> Sub Total</h5>
</td>
</tr>
</thead>
<tbody id="tablefinalbody"></tbody>
</table>