I'm performing an AJAX request where I populate a table. I want to provide a number in each row of the table to indicate where that row lies in relation to the whole table, AKA a column in my table that starts at 1 and increments by 1.
I know that PHP has something built into it already where you can do something like i++ and it will increment the value for you, however, I'm having trouble implementing this with javascript.
My code looks like this right now. Can you help me figure out how to ensure that 'i' actually increments?
I know that PHP has something built into it already where you can do something like i++ and it will increment the value for you, however, I'm having trouble implementing this with javascript.
My code looks like this right now. Can you help me figure out how to ensure that 'i' actually increments?
Code:
var RankPlayers = function(obj) { var i = 0; i++; var tr = $( '<tr><td>'+ i +'</td><td>'+obj.name+' ('+obj.position+' '+obj.team+')</td><td>'+obj.value+'</td></tr>' ); $('#rank').append( tr ); }
Comment