首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

循环输出有关问题

2012-03-11 
循环输出问题for(varintLoop1intLoopdays.length-1intLoop++)document.write( TDclasscalendarTdi

循环输出问题
for   (var   intLoop   =   1;   intLoop   <   days.length-1;   intLoop++)
  document.write( " <TD   class=calendarTd   id=diary   align= 'center '> "   +   days[intLoop]   +   " </TD> ");

在上面的语句中,要在intloop为偶数的时候,单元格背景是一种图片,为奇数时单元格背景为另一个图片!怎么弄,谢谢?

[解决办法]
for (var intLoop = 1; intLoop < days.length-1; intLoop++)
{document.write( " <TD class=calendarTd id=diary align= 'center ' "
if(intLoop%2==1)
{document.write( "bgcolor= '#ffffff ' ");}
else
{document.write( "bgcolor= '#ffff00 ' ");}

{document.write( "> " + days[intLoop] + " </TD> ");
}

热点排行