读书人

循环输出有关问题

发布时间: 2012-03-11 18:15:39 作者: rapoo

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

读书人网 >JavaScript

热点推荐