複数選択のjqueryドロップダウンでは、項目がチェックされている場合は配列に移動し、項目がチェックされていない場合はその配列から削除されます。やった:
var optionValues = [];
$("#myselect").change(function() {
$("select option:selected").each(function() {
optionValues.push($(this).val());
});
$('select option:not(:selected)').each(function() {
itemtoRemove = $(this).val();
optionValues.splice($.inArray(itemtoRemove, optionValues), 1);
});
$('#this').val(optionValues.join());
}).trigger( "change" );
<input type="text" id="this">
しかし、テキストボックスには何も表示されません。何か案が?