Most of the answer were outdated,
Here selecting and deselecting in two different ways
$('#selectall').click(function() {
$("#studentremain option").prop("selected", true);
});
$('#deselectall').click(function() {
$("#studentremain option").val([]);
});