We help IT Professionals succeed at work.
Get Started

How can I remove dollar sign ($) from a string when parsing it?

Last Modified: 2012-05-09
I  have the attached function that adds values in a table column and dispalys the value in a span.  Got it.  I've since changed the numbers coming in to the table so they have $ currency notation.  How can I strip that away before performing the math?  I've tried adding .replace("$","") in several places, but it isn't working -- either because it just doesn't work or I'm doing something wrong.


var totalOwed = 0;
var rowsOwed = $("#summaryTable tr:gt(0)");
rowsOwed.children("td:nth-child(3)").children("span").each(function() {
    totalOwed += parseFloat($(this).html());
$("#ctl00_ContentPlaceHolder1_lblTotalOwedProject").html("$" + totalOwed.toFixed(2));

Open in new window

Watch Question
Distinguished Expert 2020
This problem has been solved!
Unlock 2 Answers and 10 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE