jquery获取当前选项的属性值a

时间:2022-09-14 21:36:15
<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.js"></script>
</head>
<body>
     <select  name="kinds_id" onchange='get_my_datas(this);' >
        <option value="0">≡ 请选择 ≡</option>
            <option value="1" a="1">北京</option>
            <option value="2" a="2">天津</option>
            <option value="3" a="3">上海</option>
            <option value="4" a="4">重庆</option>
    </select>
</body>
<script type="text/javascript">
/*jquery获取当前选项的属性值a*/
    function get_my_datas(e){
        var get_a_num=$(e).find("option:selected").attr("a");
        alert(get_a_num);
    }
</script>
</html>