jQuery multiselect with header和default selected item

时间:2015-05-30 11:53:14

标签: jquery html multi-select

我想将multiselect与标头和默认值结合起来。但我的标题无法显示。

<head>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
    <link href="${pageContext.request.contextPath}/css/multi-select.css" media="screen" rel="stylesheet" type="text/css">
  </head>
  <body>
    <select multiple="multiple" id="my-select" name="my-select[]">
      <option value='elem_1'>elem 1</option>
      <option value='elem_2'>elem 2</option>
      <option value='elem_3'>elem 3</option>
      <option value='elem_4'>elem 4</option>
    </select>
    <script src="${pageContext.request.contextPath}/js/jquery.multi-select.js" type="text/javascript"></script>

    <script>
    $(document).ready(function() {
        $('#my-select').multiSelect();
        $('#my-select').multiSelect({    
              selectableHeader: "<div class='custom-header'>Selectable Members</div>",
              selectionHeader: "<div class='custom-header'>Selection members</div>", 
            });
        $('#my-select').multiSelect('select', [ 'elem_1']);
    });
    </script>
  </body>

顺便说一句,我的switch.png也没有出现,如果你知道原因,请指导我。

enter image description here

0 个答案:

没有答案