javascript - How to get to a child of a parent when multiple exist? -


there problem following code. trying increase dollar amount numbers independently (by 0.01 per click). seems work on first "content" class, not on other 2. each of these identical besides 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 function fine. converting float , seems increase 0.01 not intentional...

for me, code works without unexpected behavior... nothing. when change this

amount = parsefloat(amount) + 0.01; 

the increase button increases individual numbers 0.01


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -