[英]why am I getting NaN value?
我试图弄清楚valInt为什么返回NaN以及如何解决它以便存储存款价值。
*编辑:自发布以来进行了一些更改。 我仍然需要NaN来支付余额。
// JS
`function depositMoney () {
//Select the balance amount
let acctBal = $('.check-balance')
let chkBal = acctBal
let chkBalVal = chkBal.html()
console.log(chkBalVal)
//Needs to accept input.
let input = $('.input')
let depositVal = parseInt(input.val())
console.log('Deposit amount: ' + depositVal)
//Collect info from balance.
let valInt = parseInt(chkBalVal)
console.log('Current balance is: ' + valInt)
//Displaying the checking amount.
let sumTot = (depositVal + valInt)
console.log('Total here:' + sumTot)
acctBal.html('$' + (depositVal + valInt))
}`
// HTML
`<div id="checking" class="account">
<h2>Checking</h2>
<div class="check-balance">$0</div>
<input class="input" type="text" placeholder="enter an amount" />
<input class="deposit" type="button" value="Deposit" />
<input class="withdraw" type="button" value="Withdraw" />
</div>`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.