I have an array called prices
and another called orderT
I want to check if it's of a certain orderType then I do certain transactions with prices[i]
if it's a different type then another transaction (only 2 types of orders).
我有一个名为price的数组和另一个名为orderT的数组我想检查它是否是某个orderType然后我用price [i]进行某些交易,如果它是另一种类型然后是另一种交易(只有2种类型的订单)。
So far I can iterate through prices (using accounting.js plugin):
到目前为止,我可以迭代价格(使用accounting.js插件):
function processTotal(){
var prices = $('.prices');
var orderT = $('.orderType');
var total = 0;
$.each(prices, function(i, e){
total += accounting.unformat(prices[i].textContent);
});
total = parseFloat(total);
$('#sum').text(accounting.formatMoney(total, "€", 2, ".", ","));
}
the prices part works very well, but I can't figure how to also go over the orderT
to check.
价格部分运作良好,但我无法想象如何也检查订单。
EDIT
orderT
and prices
are related and are in a table, I can't post all the table as it is quite big but it's basically:
orderT和价格是相关的,并且在一个表中,我不能发布所有表,因为它很大但它基本上是:
<td>order_type</td>
<td>$00.00</td>
1 个解决方案
#1
6
Try this(assuming the number of .prices is same as .orderType):
试试这个(假设.prices的数量与.orderType相同):
$.each(prices, function(i, e){
var orderType = orderT [i];
if(orderType.textContent == "2"){
//Do Something
} else {
//total += accounting.unformat(prices[i].textContent);
//Do Something
}
});
Looks like the .price and .orderType are related. If you can post the HTML, this code can be improved to use the siblings/other selectors to access .price and corresponding .orderType
看起来.price和.orderType是相关的。如果您可以发布HTML,可以改进此代码以使用兄弟/其他选择器来访问.price和相应的.orderType
#1
6
Try this(assuming the number of .prices is same as .orderType):
试试这个(假设.prices的数量与.orderType相同):
$.each(prices, function(i, e){
var orderType = orderT [i];
if(orderType.textContent == "2"){
//Do Something
} else {
//total += accounting.unformat(prices[i].textContent);
//Do Something
}
});
Looks like the .price and .orderType are related. If you can post the HTML, this code can be improved to use the siblings/other selectors to access .price and corresponding .orderType
看起来.price和.orderType是相关的。如果您可以发布HTML,可以改进此代码以使用兄弟/其他选择器来访问.price和相应的.orderType