日期:2014-05-16 浏览次数:20601 次
<script language="javascript" type="text/javascript">
function change(){
alert("dd");
}
function clk(){
var selOption=document.getElementById("select");
selOption.selectedIndex=2;
}
</script>
<body> <input type="button" onclick="clk()" value="click" /> <select name="select" id="select" onchange="change()"> <option>aa</option> <option>bb</option> <option>cc</option> </select> </body>
<script language="javascript" type="text/javascript">
function change(){
alert("dd");
}
function clk(){
var selOption=document.getElementById("select");
selOption.selectedIndex=2;
change();
}
</script>
------解决方案--------------------
在程序中改变选择项是不会触发select的onChange()事件的,必须显示地触发此时间,也就是在
selOption.selectedIndex=2;