开发者

javascript date and loop check

Hey all, this is the code i have to check for a day thats equal to the list of days in the comma seperated list:

for(var i = 0; i < daysHidden.length; i++){
   if (daysHidden[i] == d.getDate());
   {
      alert(daysHidden[i] + '=' + d.getDate());  
   }
}

the daysHidden = 1 (its the only thing in the list April 1st is already gone and todays the 2nd so 1 is the only one in the list)

and d.getDate() has 1-30 (for april)

When i run the code, however, it keeps looping through the if code when it should only loop once (when it finds that 1=1

However, i keep getting the alert box that says:

1=1

1=2

1=3

etc.... 1=30

So i do not know what i am doing incorrect? I already tried putting them as strings:

 if (daysHidden[i开发者_如何学Python].ToString == d.getDate().ToString);

But that doesnt seem to work.... Any help would be great :)

David


You have extra semicolon in your if clause. It simply doesn't work

if (daysHidden[i] == d.getDate()); <-- here
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜