Javascript IE8解析浮点问题

Javascript IE8解析浮点问题,javascript,jquery,internet-explorer-8,Javascript,Jquery,Internet Explorer 8,在IE8中,我得到以下错误: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.4; OfficeLiveP

在IE8中,我得到以下错误:

Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; Tablet PC 2.0; .NET4.0C) Timestamp: Mon, 11 Apr 2011 12:36:39 UTC Message: Object doesn't support this property or method Line: 102 Char: 4 Code: 0 URI: http://www.geoffmeierhans.com/js/jquery/appone.js 有人知道为什么会这样吗

谢谢你能试试这个吗

$('#submit').click(function() {
  var mpg= $('#mpg').val();
  if(mpg=='') {
    alert("The average cannot be empty");
    $('#mpg').focus();
    return false; // cancel submission
  } 

  if (isNaN(mpg)) {
    alert("The value you entered is not a valid number");    
    $('#mpg').focus();
    return false; // cancel submission
  } 
  mpg = parseFloat(mpg);
  if (mpg==0) {
    alert("MPG cannot be 0"); // or you will divide by 0 later    
    $('#mpg').focus();
    return false; // cancel submission
  } 
  var distance = $('#distance').val();
  distance = isNaN(distance)? 0: parseFloat(distance);
  var costlitre = $('#costlitre').val()
  costlitre = isNaN(costlitre)?0: parseFloat(costlitre);

  // Work out litres needed
  if(symbol=='$') {
    gallons = distance / mpg;
    cost = gallons * costlitre
    cost = cost.toFixed(2);
  } else {
    gallons = distance / mpg;
    litresneeded = gallons * litres;
    cost = litresneeded * costlitre;
    cost = cost.toFixed(2);
  }
  $('#total').html(symbol+cost);
  $('#four').fadeOut("slow", function() {
    Cufon.replace('h1, p, .tip, #units, #price, #total', { color: '-linear-gradient(#fff, #fff)'});
    $('#five').fadeIn("slow");
  });
  return false; // cancel submission - change to true to submit
}
你能试试这个吗

$('#submit').click(function() {
  var mpg= $('#mpg').val();
  if(mpg=='') {
    alert("The average cannot be empty");
    $('#mpg').focus();
    return false; // cancel submission
  } 

  if (isNaN(mpg)) {
    alert("The value you entered is not a valid number");    
    $('#mpg').focus();
    return false; // cancel submission
  } 
  mpg = parseFloat(mpg);
  if (mpg==0) {
    alert("MPG cannot be 0"); // or you will divide by 0 later    
    $('#mpg').focus();
    return false; // cancel submission
  } 
  var distance = $('#distance').val();
  distance = isNaN(distance)? 0: parseFloat(distance);
  var costlitre = $('#costlitre').val()
  costlitre = isNaN(costlitre)?0: parseFloat(costlitre);

  // Work out litres needed
  if(symbol=='$') {
    gallons = distance / mpg;
    cost = gallons * costlitre
    cost = cost.toFixed(2);
  } else {
    gallons = distance / mpg;
    litresneeded = gallons * litres;
    cost = litresneeded * costlitre;
    cost = cost.toFixed(2);
  }
  $('#total').html(symbol+cost);
  $('#four').fadeOut("slow", function() {
    Cufon.replace('h1, p, .tip, #units, #price, #total', { color: '-linear-gradient(#fff, #fff)'});
    $('#five').fadeIn("slow");
  });
  return false; // cancel submission - change to true to submit
}

b/c这个
var distance=parseFloat($('#distance').val())肯定还有其他问题
没有给您错误在IE中打开调试并确保错误在您认为的地方。
$('#distance').val()的值是多少?
?肯定还有其他问题b/c此
var distance=parseFloat($('#distance').val())
没有给您错误在IE中打开调试并确保错误在您认为的地方。
$(“#距离”).val()的值是多少?