[英]“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);
}
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.