If you are using JQuery 1.9+ then above answers will not work in Firefox.
So here is a code for latest jquery which will work in all browsers.
See live demo
Here is the code
var select_ids = [];
$(document).ready(function(e) {
$('select#myselect option').each(function(index, element) {
select_ids.push($(this).val());
})
});
function selectAll()
{
$('select#myselect').val(select_ids);
}
function deSelectAll()
{
$('select#myselect').val('');
}
Hope this will help you... :)