I think you need to get rid of the dollar sign. This will get rid of any non-numeric characters or decimal points, so will take care of any symbols - dollar sign, euro or whatever:

<script type="text/javascript">
var amt = '$7.95';
var result = amt.replace(/[^\d\.]/g,"");
alert(parseInt(result));
</script>

-- Josh

----- Original Message ----- From: "cfdvlpr" <[EMAIL PROTECTED]>
To: "jQuery (English)" <[email protected]>
Sent: Tuesday, August 07, 2007 3:17 PM
Subject: [jQuery] Convert Text to Int



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