js年份下拉框

  <div id="divValue">test...</div>测试

 //年份 
    <select id="year"></select>
   <script type="text/javascript">
     window.onload = function() {       
        var year = document.getElementById("year");
        var divValue = document.getElementById("divValue");

	    var date = new Date();
	    for(var i=1992;i<=date.getFullYear();i++) {
	       year.options.add(new Option(i, i));	       	
	    }
	    year.onchange = function() {
		    alert(divValue.innerHTML)//以后用到innerHTML 注意火狐不兼容innerText
		    alert(year.value)
	    }
     }
   </script>

你可能感兴趣的