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

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

計(jì)算多個(gè)范圍滑塊值

計(jì)算多個(gè)范圍滑塊值

HUX布斯 2022-09-23 21:46:49
我試圖從3范圍滑塊計(jì)算價(jià)格,但是它返回了錯(cuò)誤的結(jié)果,到目前為止我嘗試過:let result1 = 0;let result2 = 0;let result3 = 0;$('input[name="cdnvideolive"]').change(function() {  let val = parseInt($(this).val());  let price = 1000;  let result1 = price * val;  $('var').text(result1 + result2 + result3);});$('input[name="cdnvideovid"]').change(function() {  let val = parseInt($(this).val());  let price = 2000;  let result2 = price * val;  $('var').text(result1 + result2 + result3);});$('input[name="cdnvideostor"]').change(function() {  let val = parseInt($(this).val());  let price = 3000;  let result3 = price * val;  $('var').text(result1 + result2 + result3);});<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><input type="range" name="cdnvideolive" value="1" min="1" max="50" data-steps="50"><input type="range" name="cdnvideovid" value="1" min="1" max="20" data-steps="20"><input type="range" name="cdnvideostor" value="1" min="1" max="30" data-steps="30">total price: <var></var>$我想要所有范圍的總數(shù),但它返回單個(gè)總計(jì)。我做錯(cuò)了什么?
查看完整描述

1 回答

?
開滿天機(jī)

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

您需要使用全局結(jié)果,并且范圍必須從零開始。


let result1 = 0;

let result2 = 0;

let result3 = 0;


$('input[name="cdnvideolive"]').change(function() {

  let val = parseInt($(this).val());

  let price = 1000;

  result1 = price * val;

  $('var').text(result1 + result2 + result3);

});


$('input[name="cdnvideovid"]').change(function() {

  let val = parseInt($(this).val());

  let price = 2000;

  result2 = price * val;

  $('var').text(result1 + result2 + result3);

});


$('input[name="cdnvideostor"]').change(function() {

  let val = parseInt($(this).val());

  let price = 3000;

  result3 = price * val;

  $('var').text(result1 + result2 + result3);

});

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<input type="range" name="cdnvideolive" value="0" min="0" max="50" data-steps="50">

<input type="range" name="cdnvideovid" value="0" min="0" max="20" data-steps="20">

<input type="range" name="cdnvideostor" value="0" min="0" max="30" data-steps="30">

total price: <var></var>$


查看完整回答
反對(duì) 回復(fù) 2022-09-23
  • 1 回答
  • 0 關(guān)注
  • 113 瀏覽
慕課專欄
更多

添加回答

舉報(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)