私がやりたいのは、「#studentadd」選択ボックスに表示されているオプションをすべて選択ボックスから削除し、#studentselect
選択ボックスを空にできるようにすること#studentadd
です。しかし、現時点ではこれを行っていません。
私は何が間違っているのですか?
以下は、両方の選択ボックスのhtmlです。
以下は選択ボックス#studentadd
です:
<select multiple="multiple" name="addtextarea" id="studentadd" size="10">
<option value='1'>u08743 - Joe Cann</option>
<option value='4'>u03043 - Jill Sanderson</option>
<option value='7'>u08343 - Craig Moon</option>
</select>
以下は、生徒が追加する必要のある選択ボックスです。
<select id="studentselect" name="studenttextarea">
<option value='1'>u08743 - Joe Cann</option>
<option value='4'>u03043 - Jill Sanderson</option>
<option value='7'>u08343 - Craig Moon</option>
</select>
以下はjqueryです:
$('#studentadd option').attr('selected', 'selected');
var selectedOption = $('select#studentadd');
$('select#studentselect').remove(selectedOption.html());