javascript获得select的value
1 <!DOCTYPE html> 2 <html lang="en"> 3 4 <head> 5 <meta charset="UTF-8"> 6 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 7 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 8 <title>Document</title> 9 </head> 10 11 <body> 12 <script> 13 window.onload = function() { 14 let selectElt = document.getElementById("mySelect"); 15 selectElt.onchange = function() { 16 alert(selectElt.value); 17 } 18 } 19 </script> 20 <select name="mySelect" id="" onchange="alert(this.value);"> 21 <option value="">--请选择省份--</option> 22 <option value="001">河北省</option> 23 <option value="002">河北省</option> 24 <option value="003">河北省</option> 25 <option value="004">河北省</option> 26 </select> 27 </body> 28 29 </html>