I am trying hard to calculate the total amount from the dynamic text fields I am creating. I am doing this in asp.net and jquery.

I am trying this with classes first. This is because when I loop through the text fields to create them, they cannot create matching ids so I have no idea what they would be called at runtime.
Each text field has the same class called "test"

<span id="total-cost" style="padding-right:20px">$0.00</span><button type="button" id="calculate-cost" class="button">Calculate</button>

$(document).ready ( function () {
$("#calculate-cost").click ( function () {
                var resultVal = 0.0;
                $(".test").each ( function() {
                    resultVal += parseFloat ( $(this).val().replace(/\s/g,'').replace(',','.'));
                $('#total-cost').html("$" + (resultVal));
When I click the calculate button the number remains the same at 0.00

Thanks for your help.