<select id=‘selState‘ class="selector"></select>
1、动态绑定select下拉框里面的值
首先清空下拉选择框
var selectObj = document.getElementById("selState");
selectObj.options.length = 0;
然后把后台传过来的值循环绑定上去
for (var i = 0; i < json.statelist.length; i++)
{
selectObj.options[selectObj.length] = new Option(json.statelist[i].statename, json.statelist[i].statename);
}
2、动态绑定值设置text为XX的项选中
$("#selState").find("option[value=‘XX‘]").attr("selected", true);
3、获取当前选中项的value
$("#selState").val();
4、获取当前选中项的text
$("#selState").find("option:selected").text();