想要做一个点击select更改时区的效果,下面是js代码,请大神帮忙看看哪里出了问题,尽量详细点,我是菜鸟 10
<scripttype="text/javascript">window.onload=function(){varmov=document.getElementById...
<script type="text/javascript">
window.onload=function() {
var mov = document.getElementById("move");
var a = 0;
var b, c, d, e, n;
function aaa() {
mov.style.visibility = a++ % 2 ? "hidden" : "visible";
}
setInterval(aaa, 1000);//上面的是设置冒号闪动;
var time = document.getElementsByTagName("select");
if(time&&time.addEventListener) {
time.addEventListener("change", function (e) {
var ev = e || window.event;
var target = ev.target || ev.srcElement;
setInterval(t02(target.value), 1000);
}, false)
}
function t02 (n){
var newDate = new Date();
b = newDate.getHours()+n;
c = newDate.getDate();
d = newDate.getMonth()+1;
e = newDate.getFullYear();
if(b >23){
b=b-24;
c++;
return b ;
if(c >31){
c=1;
d++;
return c ;
if(d >12){
d=1;
e++;
return d, e ;
}}};
document.getElementById("year").innerText=e;
document.getElementById("moon").innerText=d;
document.getElementById("date").innerText=c;
document.getElementById("hour").innerText=b;
document.getElementById("min").innerText =newDate.getMinutes();
document.getElementById("second").innerText =newDate.getSeconds();
}
}
</script> 展开
window.onload=function() {
var mov = document.getElementById("move");
var a = 0;
var b, c, d, e, n;
function aaa() {
mov.style.visibility = a++ % 2 ? "hidden" : "visible";
}
setInterval(aaa, 1000);//上面的是设置冒号闪动;
var time = document.getElementsByTagName("select");
if(time&&time.addEventListener) {
time.addEventListener("change", function (e) {
var ev = e || window.event;
var target = ev.target || ev.srcElement;
setInterval(t02(target.value), 1000);
}, false)
}
function t02 (n){
var newDate = new Date();
b = newDate.getHours()+n;
c = newDate.getDate();
d = newDate.getMonth()+1;
e = newDate.getFullYear();
if(b >23){
b=b-24;
c++;
return b ;
if(c >31){
c=1;
d++;
return c ;
if(d >12){
d=1;
e++;
return d, e ;
}}};
document.getElementById("year").innerText=e;
document.getElementById("moon").innerText=d;
document.getElementById("date").innerText=c;
document.getElementById("hour").innerText=b;
document.getElementById("min").innerText =newDate.getMinutes();
document.getElementById("second").innerText =newDate.getSeconds();
}
}
</script> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询