<select id="selectYear" οnchange="yearChange(this.options[this.selectedIndex].text)">
<option>2010</option>
<option>2011</option>
<option>2012</option>
<option>2013</option>
</select>
<script type="text/javascript">
function yearChange(year){
alert(year);
}
</script>
可以
<select id="selectYear">
<option>2010</option>
<option>2011</option>
<option>2012</option>
<option>2013</option>
</select>
<script type="text/javascript">
var selectYear=document.getElementById("selectYear");
selectYear.οnchange=yearChange;
function yearChange(){
alert(this.options[this.selectedIndex].text);
}
</script>
也可以。。。
我晕啊,为啥当时就不可以了??可惜代码已经删了,还听二哥的说什么要加上下面这些毛线才行
var selectYear=document.getElementById("selectYear");
selectYear.options[selectYear.selectedIndex].selected=true;