2 回答

TA貢獻1797條經(jīng)驗 獲得超4個贊
您可以將 id 設置為 span,然后將文本設置為 300 或 100
<span id="price">$100</span>
<scrit>
document.getElementById("price").innerHTML = "$300";
</script>

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 應用程序的情況下工作。
添加回答
舉報