1 <!doctype html> 2 <html lang="en"> 3 ?<head> 4 ??<meta charset="UTF-8"> 5 ??<meta name="Generator" content="EditPlus?"> 6 ??<meta name="Author" content=""> 7 ??<meta name="Keywords" content=""> 8 ??<meta name="Description" content=""> 9 ??<title>获取下拉菜单中的value</title>10 ?</head>11 ?<body>12 ????<script type="text/javascript">13 ????????function getValue(jhgfds){14 ????????????alert(jhgfds);15 ????????}16 ????????function getName(gfdsa){17 ????????????alert(gfdsa);18 ????????}19 ????</script>20 21 ????<select onchange="getValue(this.value)">22 ????????<option value="">--请选择市--</option>23 ????????<option value="001" >石家庄市</option>24 ????????<option value="002" >石家庄市</option>25 ????????<option value="003" >保定市</option>26 ????</select>27 28 ????<input type="text" onblur="getName(this.value)">29 ??30 ?</body>31 </html>
change事件在下拉列表选中项改变的时候发生。
以下的this是什么?this.value又是什么?
this代表当前的下拉列表对象
this.value代表当前下拉列表选中项的value
blur事件 onblur事件句柄:当失去焦点的时候触发
JS-获取下拉列表中的value(change和blur)
原文地址:https://www.cnblogs.com/xiuxiu123456/p/8461373.html