Add the multiple attribute to your select box first so that you can have multiple values selected and then something like this would be sufficient since you're using jQuery.
//for selection of all.
$('#studentremain option').attr('selected','selected');
//for removal of selection.
$('#studentremain option').removeAttr('selected');
You can try prop and removeProp in the place of attr.