首页 > 代码库 > jquerymobile知识点:select的动态帮定

jquerymobile知识点:select的动态帮定

代码:

<div data-role="navbar">                <ul>                    <li>                        <select name="select-choice-min" id="select_cata" data-mini="true" data-corners="false" data-ajax="false">                        <option>全部分类</option>                        </select>                    </li>                    <li>                        <select name="select-choice-min" id="select_pin" data-mini="true" data-corners="false" data-ajax="false">                        <option>全部品牌</option>                        </select>                    </li>                </ul>            </div>

javascript:

//获商品分类列表    function GetBindProductCata() {        var cata = $("#select_cata");        $.ajax({            type: "POST",            url: "/Ashx/Boicp_Company_GoodList.ashx?MethodName=GetCata&date=" + new Date().getTime() + "",            data: "",            dataType: "json",            success: function (data) {                data = eval(data);                var html = "";                html += "<option value=http://www.mamicode.com/‘-1‘>全部分类";                $.each(data.List, function (i, item) {                    html += "<option value=http://www.mamicode.com/‘" + unescape(item.Classid) + "‘>" + unescape(item.ClassName) + "</option>";                });                cata.html(html.replace("undefined", ""));            },            error: function (data) {                $("#select_cata").html("数据有误!");            }        });    }

最后获取select的ID值:

$("#select_cata").change(function () {        var cataID = $("#select_cata").val();        alert(cataID);    });

jquerymobile知识点:select的动态帮定