indexing - Using Jquery to append div index within same div -


i have basic set-up this:

<div class="stop">     <span class="point"></span> </div> <div class="stop">     <span class="point"></span> </div> 

and append index of div.stop within nested span.point of each, this:

<div class="stop">     <span class="point">1</span> </div> <div class="stop">     <span class="point">2</span> </div> 

this jquery i'm using, it's not working:

$("div.stop").each(function() {     var stopnumber = $("div.stop").index(this);     $("div.stop span.point").append(stopnumber); }); 

thanks in advance tips or suggestions.

-brian

there's no need index call, .each supplies index parameter callback:

$("div.stop").each(function(n) {     $('span.point', this).append(n + 1); }); 

see http://jsfiddle.net/55abr/


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -