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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何根據(jù)單擊的按鈕更改跨度文本?

如何根據(jù)單擊的按鈕更改跨度文本?

慕田峪9158850 2021-11-18 16:25:02
我想在用戶點擊它們后更改 html 頁面上顯示的數(shù)量。有 2 個按鈕,點擊每個按鈕后,它應該將它們定向到一個新的 html,數(shù)量應該相應地改變。我知道這不是真正的方法,但我不確定我還能怎么做。目前,我只能附加所有金額。<button onclick="myFunction1()" type="submit" id="one">BUY</button><button onclick="myFunction2()" type="submit" id="two">BUY</button>function myFunction1() {    window.location='pay.html';};function myFunction2() {    window.location = 'pay.html';}; <span class="title" id="total"></span> <span class="title" id="total2"></span>(function () {    "use strict";    $().ready(function () {    })    myFunction1()    function myFunction1() {        var totalamt = '$100';        $('#total').html("<span style='float:right'>" + "Total:" +         totalamt + "</span>");    }})();(function () {    "use strict";    $().ready(function () {    })    myFunction2()    function myFunction2() {        var totalamt2 = '$300';        $('#total2').html("<span>" + "Total:" + totalamt2 +         "</span>");    }})();想要實現(xiàn)的結果:例如,通過單擊第一個按鈕,將用戶重定向到 pay.html 并顯示 $100。通過單擊第二個按鈕,重定向到相同的 html(pay.html),顯示 $300。請幫助非常感謝。
查看完整描述

2 回答

?
繁星coding

TA貢獻1797條經(jīng)驗 獲得超4個贊

您可以將 id 設置為 span,然后將文本設置為 300 或 100


 <span id="price">$100</span>

   <scrit>

   document.getElementById("price").innerHTML = "$300";  

</script>


查看完整回答
反對 回復 2021-11-18
?
鴻蒙傳說

TA貢獻1865條經(jīng)驗 獲得超7個贊

使用參數(shù)發(fā)送GET請求pay.html:


window.location='pay.html?amount=100';

通過JS訪問參數(shù):


var url= new URL(document.location).searchParams;

var amount=url.get("amount");

var totalamt = '$'+ amount;

$('#total').html("<span style='float:right'>" + "Total:" + totalamt + "</span>");

你的html.html:


<button onclick="myFunction1()" type="submit" id="one">BUY</button>

<button onclick="myFunction2()" type="submit" id="two">BUY</button>

function myFunction1() {

    window.location='pay.html?amount=100';

};


function myFunction2() {

    window.location = 'pay.html?amount=300';

};

支付.html:


 <span class="title" id="total"></span>

var url = new URL(document.location).searchParams;//Getting search params

var amount = url.get("amount"); //Getting value of amount from parameters

var totalamt = '$'+ amount;

$('#total').html("<span style='float:right'>" + "Total:" + totalamt + "</span>");

這也可以在沒有 Real 應用程序的情況下工作。


查看完整回答
反對 回復 2021-11-18
  • 2 回答
  • 0 關注
  • 160 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號