0

Hello i want to do a count from 1 to 30 (1,2,3,4,5,6,7,8,9 etc) with javascript I did this

var i = 1;
    if(i<=30)
    {
        i++;
    }

    '<span>#'+i+'</span>'

all good but the count starts from 0 not 1 as wanted

4
Contributors
4
Replies
24
Views
6 Months
Discussion Span
Last Post by SimonIoa
0

The code you presented does not count 1,2,3,4,5 ... not from 0 or 1 or otherwise. As diafol pointed out, you need a loop.

0

OK. I knew from the beggining that it would sound crazy but it does loop because i put it in loop. I knew that the proper solution would be diafol's answer. But i dont know how i could use a for loop since i use $.each( data, function( i, data )in the first place.

if( data.length )
            {
                $.each( data, function( i, data )
                {
                 html = '<span>#'+i+'</span>';

Edited by SimonIoa

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.