代码:
<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='-1'>全部分类</option>"; $.each(data.List, function (i, item) { html += "<option value='" + 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); });