select中的option被選中時頁面的跳轉

 1 <!DOCTYPE html>
 2   <html lang="en">
 3     <head>
 4       <meta charset="UTF-8">
 5       <title>Document</title>
 6       <script src='js/jquery.min.js'></script>
 7     </head>
 8   <body>
 9     <select name="" id='selectId'>
10       <option value="0">--請選擇--</option>
11       <option value="1">a</option>
12       <option value="2">b</option>
13       <option value="3">c</option>
14 
15     </select>
16 
17     <script>
18     $(function (){
19       $('#selectId').on('change',function(){
20         var selectId = $('#selectId option:selected');
21         if(selectId.val()==1){
22           window.open('pink.html');
23         }else if(selectId.val()==2){
24           window.open('blue.html');
25         }else if(selectId.val()==3){
26 
27           window.open("green.html");
28         })
29 
30     });
31     </script>
32   </body>
33 </html>

 

window.open();是jquery中用來打開連接的地址。pink.html、blue.html、green.html這些是要跳轉到的頁面。html

相關文章
相關標籤/搜索