简体   繁体   English

“ Bada”-此JavaScript代码段是怎么回事

[英]“Bada” - what's going on with this javascript snippet

I'm trying to loop and create several calendars on a page. 我正在尝试循环并在页面上创建多个日历。

I'm failing. 我失败了

My loop is returning "bada" - what's that? 我的循环返回“ bada”-那是什么?

for (i=1; i<3; i++) {
$("#jqxCalendar" + i).jqxCalendar({
width: '200px',
height: '200px',
enableTooltips: true
});
alert (i);
}

http://jsfiddle.net/8oorztjt/ http://jsfiddle.net/8oorztjt/

In your loop, you forgot to put the var keyword before the i . 在循环中,您忘记将var关键字放在i之前。 As such, it appears you aren't referring to the i index it would appear you are. 因此,看起来您并不是在指的是i索引。 I don't know what the i variable is being used for elsewhere that it's containing the string "bada", but changing your first line to for (var i=1; i<3; i++) { will create a new variable i and cause your loop to behave as you are expecting. 我不知道i变量用于包含字符串“ bada”的其他地方是什么,但是将第一行更改为for (var i=1; i<3; i++) {将创建一个新变量i和使您的循环表现出预期的效果。

i更改为类似ii的其他参数。似乎正在使用该日历。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM