zoukankan      html  css  js  c++  java
  • js select onchange

    	<select id="selectYear" onchange="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.onchange=yearChange;
    	function yearChange(){
    		alert(this.options[this.selectedIndex].text);	
    	}
    </script>
    

    也可以。。。

    我晕啊,为啥当时就不可以了??可惜代码已经删了,还听二哥的说什么要加上下面这些毛线才行

    	var selectYear=document.getElementById("selectYear");
    	selectYear.options[selectYear.selectedIndex].selected=true;
    

      

  • 相关阅读:
    第二次作业
    构造之法现代软件工程
    软件工程的作业五个问题!
    第四次作业
    第五次作业
    软件工程第二次作业
    第五次作业·
    第五次作业
    软件工程第二次作业
    软件工程第一次作业
  • 原文地址:https://www.cnblogs.com/frostbelt/p/2388700.html
Copyright © 2011-2022 走看看