1. 程式人生 > >多選外掛multiselect.js

多選外掛multiselect.js

官方網址:http://loudev.com/

html:

<html>
  <head>
    <link href="path/to/multiselect.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> ... <option value='elem_100'>elem 100</option> </select> <script src="path/to/jquery.multi-select.js" type="text/javascript"></script> </body> </html>

JavaScript:

$('#my-select').multiSelect();
$('#my-select').multiSelect({ keepOrder: true });//按新增的先後排序

獲取選中的值(移到右側的值)的方法:

$('#my-select').val();