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
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
for( i = 1; i <= 30; i++ ){
...
}
Or am I missing something?
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.
Just for you. Read and run http://www.w3schools.com/code/tryit.asp?filename=FCCZ4KEI353K
Nope, never looped. You should fix that.
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>';
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.