There is problem with the following code. I am trying to Increase the dollar amount for all the numbers independently (by 0.01 per click). But it only seems to work on the first "content" class, not on the other 2. Each of these are identical besides the amount.
Layout:
<div class="content">
<div class="item"><span class="number">$10.11</span><a href="#" class="incNumber"> Increase</a></div>
</div>
<div class="content">
<div class="item"><span class="number">$5.04</span><a href="#" class="incNumber"> Increase</a></div>
</div>
<div class="content">
<div class="item"><span class="number">$3.45</span><a href="#" class="incNumber"> Increase</a></div>
</div>
Script:
$(function () {
$(".incNumber").click(function() {
brother = $(this).closest('div').children('.number');
amount = $(brother).html().replace(/[^\d\.]/g, "");
amount = parseFloat(amount);
$(brother).html('$'+String(amount.toFixed(2)));
return false;
});
});
This script seems to function fine. converting it to a float and then back seems to increase it by 0.01 however this is not intentional...