您现在的位置是:首页 > 电脑技术查询 > web开发

循环输出有关问题

编辑:chaxungu时间:2022-10-02 23:21:52分类:web开发

循环输出问题
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> ");
}