第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何在結(jié)帳總額的末尾添加零?

如何在結(jié)帳總額的末尾添加零?

慕尼黑5688855 2023-09-18 15:19:37
我想在結(jié)帳總金額上有一個(gè)零,因?yàn)樵谀┒艘粤憬Y(jié)尾的產(chǎn)品上,總金額顯示為這樣 £1.5那么,如何更改它以像這樣顯示1.50英鎊而不會(huì)弄亂其他產(chǎn)品呢?任何代碼片段都將不勝感激。<!DOCTYPE html><html><head>   </head><body><header class="main-header">    <nav class="main-nav nav">    </nav></header>    <div class="shop-items">        <div class="shop-item">            <span class="shop-item-title">Album 0</span>&nbsp;            <div class="shop-item-details"><span class="shop-item-price">£12.50</span>            <button class="btn btn-primary shop-item-button" type="button">ADD TO BASKET</button>        </div>  <div class="shop-item">        <span class="shop-item-title">Album 2</span>&nbsp;        <div class="shop-item-details">            <span class="shop-item-price">£14.50</span>                       <button class="btn btn-primary shop-item-button" type="button">ADD TO BASKET</button>        </div>        <div class="shop-item">        <span class="shop-item-title">Album 4</span>&nbsp;        <div class="shop-item-details"><span class="shop-item-price">£19.50</span>        <button class="btn btn-primary shop-item-button" type="button">ADD TO BASKET</button>    </div>        </div></section>    <div class="shop-items">        <div class="shop-item">            <span class="shop-item-title">Album 6</span>&nbsp;            <div class="shop-item-details"><span class="shop-item-price">£19.50</span>            <button class="btn btn-primary shop-item-button" type="button">ADD TO BASKET</button>        </div>     <div class="shop-items">        <div class="shop-item">            <span class="shop-item-title">Album 8</span>&nbsp;            <div class="shop-item-details"><span class="shop-item-price">£19.50</span>            <button class="btn btn-primary shop-item-button" type="button">ADD TO BASKET</button>        </div>   
查看完整描述

1 回答

?
慕森卡

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超8個(gè)贊

在代碼末尾,將此代碼編輯為totaltotal.toFixed(2)


編輯:


在代碼的最后一行


function updateCartTotal() {

var cartItemContainer = document.getElementsByClassName('cart-items')[0]

var cartRows = cartItemContainer.getElementsByClassName('cart-row')

var total = 0

for (var i = 0; i < cartRows.length; i++) {

    var cartRow = cartRows[i]

    var priceElement = cartRow.getElementsByClassName('cart-price')[0]

    var quantityElement = cartRow.getElementsByClassName('cart-quantity-input')[0]

    var price = parseFloat(priceElement.innerText.replace('£', ''))

    var quantity = quantityElement.value

    total = total + (price * quantity)

}

total = Math.round(total * 100) / 100

document.getElementsByClassName('cart-total-price')[0].innerText = '£' + total.toFixed(2)

}


查看完整回答
反對(duì) 回復(fù) 2023-09-18
  • 1 回答
  • 0 關(guān)注
  • 116 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)