dimanche 14 août 2016

Add class to all by clicking checkbox

With this code, i get all the checkboxes checked:

$(".checkAllCheckboxes").click(function()
{
    $('input:checkbox').not(this).prop('checked', this.checked);
});

With this, i add a class to the element, where the checkbox is in.

$(function()
{
    $('.table_row_checkbox').on('change',function(){
        if($(this).is(":checked")) 
        {
            $(this).parents('tr').addClass("checkbox_checked_row");
        } 
        else 
        {
            $(this).parents('tr').removeClass("checkbox_checked_row");
        }
    });
});

How can i add that class, in my first code, to all the elements, by clicking select all checkboxes?




Aucun commentaire:

Enregistrer un commentaire