<div id="remainingfunds">
<p>Remaining Funds: $<span id="remainingfundsnumber">500</span></p>
</div><!--remainingfunds-->
<div id="subtotal">
<p>Subtotal: $<span id="subtotalnumber">0</span></p>
</div><!--subtotal-->
remainingfundsnumber=parseInt(remainingfundsnumber);
subtotal = parseInt(subtotalnumber);
显然不那么简单。请帮帮我。
答案 0 :(得分:0)
使用document.getElementById()
获取所需的元素并使用所需的ID innerHTML
获取其内部html数据
remainingfundsnumber = parseInt(document.getElementById("remainingfundsnumber").innerHTML);
subtotal = parseInt(document.getElementById("subtotalnumber").innerHTML);
<div id="remainingfunds">
<p>Remaining Funds: $<span id="remainingfundsnumber">500</span></p>
</div><!--remainingfunds-->
<div id="subtotal">
<p>Subtotal: $<span id="subtotalnumber">0</span></p>
</div><!--subtotal-->