LINK:http://demo.mycodes.net/daima/Multiselect/;

HTML

<div class="muti-sel">
    <div class="col-xs-5">
        <select name="from[]" id="keepRenderingSort" class="form-control" size="8" multiple="multiple">
            <option value="1">Item 1</option>
	    <option value="2">Item 5</option>
	    <option value="2">Item 2</option>
            <option value="2">Item 4</option>
            <option value="3">Item 3</option>
        </select>
    </div>
    <div class="col-xs-2">
	    <button type="button" id="keepRenderingSort_rightAll" class="btn btn-block"><i class="glyphicon glyphicon-forward"></i></button>
	    <button type="button" id="keepRenderingSort_rightSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>
	    <button type="button" id="keepRenderingSort_leftSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>
	    <button type="button" id="keepRenderingSort_leftAll" class="btn btn-block"><i class="glyphicon glyphicon-backward"></i></button>
	</div>
	<div class="col-xs-5">
	    <select name="to[]" id="keepRenderingSort_to" class="form-control" size="8" multiple="multiple"></select>
	</div>
</div>

js

$('#keepRenderingSort').multiselect({
    keepRenderingSort: true,
    afterMoveToRight: function($left, $right, option){
        var sel_val = option.val();
	            	
    },
    afterMoveToLeft: function($left, $right, option){
    }
});
$('#keepRenderingSort').multiselect({
    right: '#js_multiselect_to_1',
    rightAll: '#js_right_All_1',
    rightSelected: '#js_right_Selected_1',
    leftSelected: '#js_left_Selected_1',
    leftAll: '#js_left_All_1'
});


参数

Nametypedefaultdescription
rightstringjQuery selectormultiselect_id_toThe select where the options are moved to
rightSelectedstringjQuery selectormultiselect_id_rightSelectedThe button that moves selected options from left to right
rightAllstringjQuery selectormultiselect_id_rightAllThe button that moves all options from left to right
leftSelectedstringjQuery selectormultiselect_id_leftSelectedThe button that moves selected options from right to left
leftAllstringjQuery selectormultiselect_id_leftAllThe button that moves all options from right to left
startUpfunction orfalseremove from left all options that are present in rightWhatever you want to do with $left and $right elements when the multiselect plugin is initialised
sortfunction orfalsesort options alphabeticallyWill sort options when an action happend into right or left elements.
beforeMoveToRightfunctionreturn trueWhatever you want to do with $left$right and option[s] elements before they are moved to right. Keep in mind that this function must return a boolean value.
true will let the action to be performed.
false will stop the action
afterMoveToRightfunctionno actionWhatever you want to do with $left$right and option[s] elements after they are moved to right.
beforeMoveToLeftfunctionreturn trueWhatever you want to do with $left$right and option[s] elements before they are moved to left. Keep in mind that this function must return a boolean value.
true will let the action to be performed.
false will stop the action
afterMoveToLeftfunctionno actionWhatever you want to do with $left$right and option[s] elements after they are moved to left.
keepRenderingSortbooleanfalseWhen you want to keep options sorted as they was rendered, keepRenderingSort must be true.
When keepRenderingSort is truesort function will be ignored.