2016/2/25 onchange 应用

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <title>onchange 商品变价格变</title>
 6 </head>
 7 
 8 <body>
 9 <select size="1" onchange="change()" id="ss">
10 <option value="1" selected="selected">可口</option>
11 <option value="2">百事</option>
12 <option value="3">非常</option>
13 </select>
14 <p>价格:<label id="aa">3</label></p>
15 </body>
16 </html>
17 <script>
18 function change()
19 {
20     var s=document.getElementById("ss").value;
21     
22     var a=document.getElementById("aa")
23     
24     if(s=="1"){
25         a.innerText="3"
26         }
27     else if(s=="2"){
28         a.innerText="4"
29         }
30     else{
31         a.innerText="5"
32         }
33     }
34 </script>

显示效果:

原文地址:https://www.cnblogs.com/haodayikeshu/p/5218822.html