下拉框选中一个选项后 触发事件

来源:互联网 发布:matlab生成无标度网络 编辑:程序博客网 时间:2024/06/03 15:02


第一个实例

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html> <head>  <script language="JavaScript">  <!--    function GaiBian(osel){if(osel.options[osel.selectedIndex].text==1){alert(11);}    }  //-->  </script> </head>  <body>  <select name='selectSS' onChange="GaiBian(this)">  <option value='1'>1 </option>   <option value='2'>2 </option>   <option value='3'>3 </option>   </select>   <select  onchange="window.location.href=this.options[this.selectedIndex].value">    <option value="http:\\www.baidu.com">百度</option>    <option value="http:\\www.google.cn">谷歌</option></select>  </body></html>


第二个实例

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html> <head>  <script language="JavaScript">  <!--    function GaiBian(osel){ var target=document.getElementById('contentid');if(osel.options[osel.selectedIndex].value==1){<pre name="code" class="html">//if(osel.options[osel.selectedIndex].text==1){
target.style.display="block"; } if (osel.options[osel.selectedIndex].value==2){target.style.display="none"; } } //--> </script> </head> <body> <select name='selectSS' onChange="GaiBian(this)"> <option value='1'>1 </option> <option value='2'>2 </option> </select> <div id="contentid" class="none">打开的内容</div> </body></html>

if(osel.options[osel.selectedIndex].value==1){
0 0
原创粉丝点击