The first
<select name="type" id="aaa" οnchange="show_sub()">
<option value="0">请选择主菜名</option>
<option value="1">白菜</option>
<option value="2">萝卜</option>
</select>
js code
function show_sub(){
alert($("#aaa").find("option:selected").attr("value"));//原生
alert($("#aaa").find("option:selected").val()); //加入jq库
}
The second
<select name="type" οnchange="show_sub(this.options[this.options.selectedIndex].value)">
<option value="0">请选择主菜名</option>
<option value="1">白菜</option>
<option value="2">萝卜</option>
</select>
js code
<script>
function show_sub(v){
alert(v);
}
</script>
Both effects are the same