1,selec2动态赋值
var temp=JSON.stringify({ id: "1|所有停车场", name: "所有停车场" }); $("#e_pid").attr("value", tempP); $("#e_pid").select2({ placeholder: "查找停车场名称(多选)", language: "zh-CN", minimumInputLength: 1, allowClear: true, multiple: true, ajax: { // instead of writing the function to execute the request we use Select2's convenient helper url: "/manage/park/index/json/index", dataType: 'json', data: function (term, page) { return { parkName: term,// search term powerpid: "1" }; }, results: function (data, page) { // parse the results into the format expected by Select2. // since we are using custom formatting functions we do not need to alter remote JSON data for (var i = 0; i
2,动态改变值
$("#e_pid").attr("value", temp); $("#e_pid").trigger('change'); //动态改变值以后必须触发改变时间。否则将不会生效
以上所述是小编给大家介绍的BootStrap select2 动态改变值的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!