0
我已經停止了我的盒頂部兩盒顯示NaN當字母被錄入到他們。我在輸入第三個字母時輸入數字,然後輸入數字1或2.我得到nan。它可能很容易,但我不能解決它?不返回南兩個瓦爾
1.<input type="text" id="first"/>
2.<input type="text" id="second" />
3.<input type="text" id="third" value="10"/>
$(document).ready(function(){
var num = 5;
$('#first').keyup(function(){
var firstValue = parseFloat($('#first').val());
var thirdValue = parseFloat($('#third').val());
if(!isNaN(firstValue))
var hi = $('#second').val(firstValue * thirdValue/num);
});
$('#second').keyup(function(){
var secondValue = parseFloat($('#second').val());
var thirdValue = parseFloat($('#third').val());
if(!isNaN(secondValue))
$('#first').val(secondValue/num * thirdValue);
});
$('#third').keyup(function(){
var firstValue = parseFloat($('#first').val());
var secondValue = parseFloat($('#second').val());
var thirdValue = parseFloat($('#third').val());
if(!isNaN(thirdValue))
$('#first').val(secondValue/num * thirdValue);
if(!isNaN(thirdValue))
$('#second').val(firstValue * thirdValue/num);
});
});
http://jsfiddle.net/n00bctrl/vory55ze/#&togetherjs=bffzvEK5wS