lint警告val()和text()被错误地调用(lint warning that val() and text() are called incorrectly)
我有:
TotalPrice = parseInt(TotalPrice*100)/100; $('input[name=EstimatedPrice]').val(TotalPrice); $('#EstimatedPriceDisplay').text(TotalPrice);而且我从lint得到了两个警告。
val()调用不正确
text()调用不正确。
通过执行以下操作,我能够消除错误调用的text()错误:
$('#EstimatedPriceDisplay').text('' + TotalPrice);但这对我来说似乎有些愚蠢。
I have:
TotalPrice = parseInt(TotalPrice*100)/100; $('input[name=EstimatedPrice]').val(TotalPrice); $('#EstimatedPriceDisplay').text(TotalPrice);and I'm getting two warnings from lint.
val() called incorrectly
text() called incorrectly.
I was able to eliminate the text() called incorrectly error by doing the following:
$('#EstimatedPriceDisplay').text('' + TotalPrice);But that seems kinda kludgy to me.
最满意答案
你想支持IE <5.5吗? 如果没有,请尝试使用.toFixed()方法 ,该方法返回一个字符串并四舍五入到指定的小数位。
TotalPrice = TotalPrice.toFixed(2);Do you want to support IE <5.5? If not, try to use the .toFixed() method, which returns a string and rounded to the specified decimal place.
TotalPrice = TotalPrice.toFixed(2);更多推荐
发布评论