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

一段js代碼,感覺判斷條件縱使為真。该怎么处理

2012-03-04 
一段js代碼,感覺判斷條件縱使為真。當系統時間是2007年5月10日。函數依舊回執行到alert( 123 )。感覺if(sho

一段js代碼,感覺判斷條件縱使為真。
當系統時間是2007年5月10日。
函數依舊回執行到alert( "123 ")。
感覺if   (showMonth=1)總是為true.
var   lastDate   =   new   Date();
//var   teshu   date
var   showMonth=lastDate.getMonth()   +   1  
alert( "showMonth= "   +   showMonth)
alert(lastDate.getMonth())
if   (showMonth=1)
{
alert( "123 ")
lastDate.setYear(lastDate.getYear()   -   1)  
lastDate.setMonth(11)

}
else
{
alert( "ddd ")
lastDate.setMonth(lastDate.getMonth())
}

[解决办法]
if (showMonth=1) ==> if (showMonth == 1)
[解决办法]
showMonth=1
改成
showMonth==1

热点排行