check uncheck checkboxes using jQuery

check uncheck checkboxes using jQuery

HTML

<p><input type="checkbox" id="selectAll" /> Check/Uncheck All</p>
<hr/>
<p>
<input type="checkbox" class="chk" /> Checkbox  1
<input type="checkbox" class="chk" /> Checkbox  2
<input type="checkbox" class="chk" /> Checkbox  3
</p>

JavaScript

$(document).ready(function(){
    $("#selectAll").click(function(){
        $(".chk").prop("checked",$("#selectAll").prop("checked"))
    }) 
});