所以我有一个价格,我得到的变量,但我不断得到“60美元”,我只想“60”。之后我需要循环遍历多个变量(价格和数量)然后写两个句子。 “订单数量为2,价格为60”“订单数量为5,价格为20”。这是尽可能接近它但循环不起作用。 2
</td>
<td class="v1_shop_cart_articles_col_qty">
5
</td>
<td class="v1_shop_cart_articles_col_price"><span class="nobreak">USD <span>60.00</span></span></td>
<td class="v1_shop_cart_articles_col_price"><span class="nobreak">USD <span>20.00</span></span></td>
</tr>
</table>
var price = document.getElementsByClassName('v1_shop_cart_articles_col_price').getElementByTagName('span')[1].innerHTML;
var qty = document.getElementsByClassName('v1_shop_cart_articles_col_qty');
for(var i=0; i<qty.length; i++) {
document.write('An order was placed with a quantity of '+
parseInt(qty[i].innerHTML, 10) + price +
'.');
}
答案 0 :(得分:0)