select标签的描述

  1、标签html与js如下代码

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
        <script type="text/javascript" src="js/jquery-2.1.0.js"></script>
    </head>

    <body>
        <select name="city" id="city_id" onchange="setAct(this)">
            <option value="1" code="0531">济南</option>
            <option value="2" code="0532">青岛</option>
            <option value="3" code="0538">泰安</option>
        </select>
        <input type="button" name=""  onclick="setact()" value="点击测试" />
        <script type="text/javascript">
            function setact(item){
                re = $("#city_id option").toArray()
                
                var tmp;
                tmp = re[0]
                re[0]=re[2]
                re[2] = tmp
                $("#city_id").html(re)
                $("#city_id option[value='2']").attr("selected",true)
                $("#city_id option").first().text("贵州")
                $("#city_id option").first().val("0")
                $("#city_id option[value='3']").attr("selected",false)
                
                $("#city_id").val("3");
                
            }
            function setAct(itme){
                console.log($("#city_id").val())
            }
        </script>

    </body>

</html>

  

 

posted @ 2019-04-12 11:57  洺剑残虹  阅读(298)  评论(0编辑  收藏  举报