select框内容改变时触发事件的实现

 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">  
 2 
 3    <html>  
 4        <head>  
 5           <title>select</title>      
 6 
 7            .list,li{list-style:none; margin:0; padding:0;}  
 8 
 9            .scroll{ width:500px; height:25px; overflow:hidden; border:1px solid #333;}  
10 
11            .scroll li{ width:500px; height:25px; line-height:25px; overflow:hidden;}  
12 
13            .scroll li a{ font-size:14px;color:#333; text-decoration:none;}  
14 
15            .scroll li a:hover{ text-decoration:underline;}  
16 
17        </style> 
18         <script type="text/javascript" src="js/jquery.min.js"></script>
19        </head>  
20 
21        <body>  
22            <div class="scroll">  
23      <select id="testSelect" οnchange="selectChange()">
24      <option value="1">测试1</option>
25      <option value="2">测试2</option>
26      <option value="3">测试3</option>
27 </select>           
28            </div>  
29          <script>
30   $("#testSelect").change(function(){
31      alert("你更新了选项")
32     }); 
33    </script>
34        </body>  
35    </html>

 

posted @ 2020-02-11 11:39  阿东123  阅读(12611)  评论(0编辑  收藏  举报