转 html select标签事件 传选中的value

<select id="hello" onchange="getContent(this.value,this.options[this.selectedIndex].text)">
<option value=1>a</option>
<option value=2>b</option>
<option value=3>c</option>
<option value=4>d</option>
</select>

以上是select的onchange方法,传了两个参数,分别是选中的option的Value(this.value)和选中的option的内同(this.options[this.selectedIndex].text)。这样就可以在onchange方法中直接使用值和内容了。

 function getContent(value,content){

alert("选中的值是"+value+"选中的内容是"+content);
}

个人分
原文地址:https://www.cnblogs.com/lierjie/p/9394664.html