开发者

loop for -javascript

what is the problem of this loop?

    for(i=0; i<18; i++)
    {
        $("'#various'+i+1").fancybox({
Something
            });
        }

it is supposed to be various1,开发者_Go百科 various2, etc

thanks


$("#various"+(i+1)).fancybox({


The i variable needs to be outside the quotes.

for(i=1; i<=18; i++) {
    $("#various"+i).fancybox({  /*...*/ });
}


Problem is bad syntax in your string concatenation.

for(var i=1; i<19; i++) {
    $('#various'+i).fancybox({
       'Something':'val'
    });
}


for(var i = 0; i < 18; i++){
    $('#various' + (i + 1)).fancybox({
       // something
    });
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜