开发者

javascript date and loop check

开发者 https://www.devze.com 2022-12-25 04:51 出处:网络
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:

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

精彩评论

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