1. 程式人生 > >bootstrap multiselect 設定多項被選中方法

bootstrap multiselect 設定多項被選中方法

var rs = data.data.reason;

            console.log("rs", rs);
            var arr = rs.split(",");
            var sel = document.getElementById("reason");
            var len = sel.options.length;
            for (var i = 0; i < arr.length; i++) {
                $("#reason option[value='" + arr[i] + "'] ").attr("selected", true);
            }
            $('#reason').multiselect('rebuild');
            $('#reason').multiselect('refresh');