Friday 1 April 2016

Select All checkboxes using jQuery

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

<script>
var noc = jQuery.noConflict();
noc(document).ready(function () {
    noc("#ckbCheckAll").click(function () {
        noc(".checkBoxClass").prop('checked', noc(this).prop('checked'));
    });
     });
</script>

<input type="checkbox" id="ckbCheckAll" />
    <p id="checkBoxes">
        <input type="checkbox" class="checkBoxClass" id="Checkbox1" />
        <br />
        <input type="checkbox" class="checkBoxClass" id="Checkbox2" />
        <br />
        <input type="checkbox" class="checkBoxClass" id="Checkbox3" />
        <br />
        <input type="checkbox" class="checkBoxClass" id="Checkbox4" />
        <br />
        <input type="checkbox" class="checkBoxClass" id="Checkbox5" />
        <br />
    </p>

No comments:

Post a Comment