Edit in JSFiddle

        $("#toggle").click(function(){
            $('.chkbox').prop('checked', $(this).prop('checked'));
        });



              
<input type="checkbox" id="toggle">Check toggle<br>
<br>
<input class="chkbox" type="checkbox" name="foo" value="1"> Example 01<br>
<input class="chkbox" type="checkbox" name="bar" value="2"> Example 02<br>
<input class="chkbox" type="checkbox" name="piyo" value="3"> Example 03<br>