当前位置: 代码迷 >> Web前端 >> 依据年份获取生肖
  详细解决方案

依据年份获取生肖

热度:199   发布时间:2012-10-08 19:54:56.0
根据年份获取生肖

<script language="JavaScript">

<!--

window.onload=function(){

?? ?var year = new Array("猪","鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗");

?? ?var y = new Array("猴","鸡","狗","猪","鼠","牛","虎","兔","龙","蛇","马","羊");

var i = document.getElementsByTagName("input")[0];

var s = document.getElementsByTagName("span")[0];

i.value="2010";

i.focus();

i.onkeyup=function(){

? ?s.innerHTML = year[(parseInt(this.value)+9)%12]+"|"+y[this.value%12];

}

}

//-->

</script>

  相关解决方案