Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could do something like this:</p> <pre><code>$("#checkallContacts").live('click', function(event) { $("#tblDisplayContacts").find("input[type=checkbox]").attr('checked', this.checked); //To Highlight if ($(this).attr("checked") == true) { $("#tblDisplayContacts").find('tr:not(#chkrowContacts)').css("background-color", "#FC9A01"); } else { $("#tblDisplayContacts").find('tr:not(#chkrowContacts)').css("background-color", "#FFF"); } }); </code></pre> <p>On a <em>side note</em>, you are using live quite a bit, are all of these tables built dynamically?</p> <p>Also looking at your example I think this can be simplified to the following this relies on a convention for your tables by class name and removes the need for an id:</p> <pre><code>$(".checkAll").live("click", function() { var $table = $(this).parents("table.t"); $table.find("input[type=checkbox]").attr('checked', this.checked); //To Highlight if ($(this).attr("checked") == true) { $table.find('tr').css("background-color", "#FC9A01"); } else { $table.find('tr').css("background-color", "#FFF"); } }); $("input[type=checkbox]:not(.checkAll)").live("click", function() { var $table = $(this).parents("table.t"); var $checkAll = $table.find(".checkAll"); var $row = $(this).parents("tr.trBorderLight"); var totalChecked = $table.find(":checked:not(.checkAll)").length; var totalCheckBoxes = $table.find("input[type=checkbox]:not(.checkAll)").length; if ($(this).attr("checked") == true) { $row.css("background-color", "#FC9A01"); if (totalChecked == totalCheckBoxes) { $checkAll.attr("checked", true); $checkAll.parents("tr.trBorder").css("background-color", "#FC9A01"); } } else { $row.css("background-color", "#FFF"); $checkAll.parents("tr.trBorder").css("background-color", "#FFF"); $checkAll.attr("checked", false); } }); </code></pre> <p>Here is an example of this on <a href="http://jsfiddle.net/markcoleman/C3dhm/13/" rel="nofollow">jsfiddle</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload