Thursday, February 12, 2015

CHECK CHECKBOX AND CHANGE ROW COLOR, CLICK ROW AND CHECK CHECKBOX AND CHANGE ROW COLOR, CLICK PARENT AND CHECK ALL CHECKBOXES



$(document).ready(function() {

             //  CHECK PARENT CHECKBOX AND SELECT ALL CHILD CHECKBOXES

   $('#selectAll').click(function(event) {  //on click    
       if(this.checked) { // check select status
        $("[name=ids]").prop("checked", true); 
        $('tr').addClass('selected');  
       }else{
        $("[name=ids]").prop("checked", false);
        $('tr').removeClass('selected');
       }
   });

             //  SELECT CHECKBOX AND CHANGE ROW COLOR
   

   $("table").on("change", ":checkbox", function() {
    if(this.checked){
    $(this).parents("tr").addClass('selected');
    }else{
    $(this).parents("tr").removeClass('selected');
    }
   });

           // CLICK ON ROW AND CHANGE ITS COLOR AND CHECKED CHECKBOX
           $('#'+tableId ).on( 'click', 'tr', function (event) {
                  if (event.target.type !== 'checkbox') {
                  $(this).toggleClass('selected');
                         $(':checkbox', this).trigger('click');
                  }       

           });

});

No comments:

Post a Comment

Scrum and Scrum master

Scrum  Scrum is a framework which helps a team to work together.  It is like a rugby team (the scrum name comes from rugby game). Scrum enco...