Oh, I thought he wanted the int "7" out of "$7.95". If you just want the float then use Erik's code, or mine without the parseInt part.

-- Josh

----- Original Message ----- From: "Erik Beeson" <[EMAIL PROTECTED]>
To: <jquery-en@googlegroups.com>
Sent: Tuesday, August 07, 2007 3:49 PM
Subject: [jQuery] Re: Convert Text to Int



Because parseInt('$7.95') is not a number. Perhaps you want:

var price = '$7.95';

var priceFloat = parseFloat(price.substring(1));

--Erik

On 8/7/07, cfdvlpr <[EMAIL PROTECTED]> wrote:

Here's my faulty code:
var temp parseInt($('td#totalPriceData_1').text());
alert(temp);

Here's what my HTML looks like:
<td id="totalPriceData_1" class="totalPriceData">

$7.95

</td>

Why does alert(temp) show me NaN for this temp var?
What is a better way to convert this text to a int?



Reply via email to