English 中文(简体)
Weird Javascript for Loop Behaviour
原标题:Weird Javascript For Loop Behaviour

顺便说一句:

for (var i=first; i<=last; i++)
{
    $("#markers").append("<div class= marker >"+i+"</div>");
}

<代码>第1 > 至2001年,last为2010年。 罚款。 问题在于我改为:

for (var i=first; i<=last; i+=1)
{
     $("#markers").append("<div class= marker >"+i+"</div>");
}

(不同最后声明不同)。 除<代码>i++外,任何改动都会导致无限循环。 它作为jsFiddle,其参数相同。 任何建议?

最佳回答

我想,first的制定方式含糊不清,可被解释为string。 因此,第一版只能被解释为增量,而第二版正用javascript被解释为扼杀。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签