qq_无心_12
2015-12-27 23:11
function window_onload()
{
var myForm = document.form1;
var nowDate = new Date();
myForm.firstDay.options[nowDate.getDate()-1].selected = true;
myForm.secondDay.options[nowDate.getDate()-1].selected =true;
myForm.secondMonth.options[nowDate.getMonth()].selected =true;
myForm.firstMonth.options[nowDate.getMonth()].selected = true;
myForm.firstYear.options[nowDate.getFullYear()-1970].selected =true;
myForm.secondYear.options[nowDate.getFullYear()-1970].selected =true;
}
//可以执行,返回firstDay,secondDay.options【】对象的值为当前时间,,
function window_onload()
{
var myForm = document.form1;
var nowDate = new Date();
myForm.firstDay.options[nowDate.getDate()-1].selected = true;
myForm.firstMonth.options[nowDate.getMonth()].selected = true;
myForm.firstYear.options[nowDate.getFullYear()-1970].selected =true;
myForm.secondDay.options[nowDate.getDate()-1].selected =true;
myForm.secondMonth.options[nowDate.getMonth()].selected =true;
myForm.secondYear.options[nowDate.getFullYear()-1970].selected =true;
}
顺序更改后,firstDay 正常返回当前日期,secondDay则无法返回当前日期,为什么???
给一下你的完整代码看一下,包括html结构
JavaScript进阶篇
468195 学习 · 21891 问题
相似问题