Select / Unselect All

Select / Unselect All in a Multi-Select

HTML

<select class="select_multiple" id="list" multiple="multiple">    
    <option>Bob's</option>    
    <option>bob</option>
    <option>bohb</option>
    <option>bhob</option>
</select>

<br />

<a href="#" id="select_all">Select All</a>
<a href="#" id="unselect_all">Unselect All</a>

CSS

body { margin: 20px; }

JavaScript

$(document).ready(function() {
    $("#select_all").click(function() {
        $("#list").each(function(){
            $("#list option").attr("selected","selected"); });
    }) ;
 
    $("#unselect_all").click(function() {
        $("#list").each(function(){
            $("#list option").removeAttr("selected"); });
    }) ;
 
});