jquery.multiSelect下拉框多选

使用multiSelect需要导入jquery.bgiframe.min.js,jquery.multiSelect.css,jquery.multiSelect.js还有一些图片,详见附件。

 

案例

 

jsp代码:

<td>部门:
         <select id="departmentId" name="roleIds" style="width:180px" multiple="multiple">
                 <c:forEach items="${depts}" var="depart">
                          <option title="${depart.name}" value="${depart.id}">${depart.name}</option>
                 </c:forEach>
           </select>
</td>

 

js代码:

$(document).ready( function() {
            $("#departmentId").multiSelect({
                    selectAll: false,
                    oneOrMoreSelected: '*',
                    selectAllText: '全选',
                    noneSelected: '请选择'
            }, function(){   //回调函数
                if($("[name='roleIds']:checked").length > 0)
                    {
                        $("#errRed").empty();
                    }
                else
                {
                        $("#errRed").text("");
                    }
            });

    });

 

取值:

官网取值:

var array_of_checked_values = $("#departmentId").multiselect("getChecked").map(function(){
        return this.value;
    }).get();

不好用,取不到,网上找了资料也存在这个问题,哪位大拿可以帮忙解答一下,3q

所以我使用var array_of_checked_values = $("#departmentId").find("span").text();取值的

你可能感兴趣的:(multiSelect,下拉框多选)