Checkbox in one table controls checkboxes in another
<p>I have the following function where a top checkbox controls other checkboxes in the table.</p>

<pre><code>var $checkboxes = $("#myTbl input[type=checkbox]:not(:first)").
        not($("#myTbl input[disabled=disabled]")).
        change(function() {
            var allIsChecked = $checkboxes.length === $checkboxes.filter(":checked").length;
            $all[0].checked = allIsChecked;     
            enableProcessTagBtn();          
        });

var $all = $("#allCheckboxes").change(function() {
    $checkboxes.attr("checked", this.checked);
    enableBtn();
});

function enableBtn() {
    if ($("#myTbl input[type=checkbox]").filter(":checked").length &gt; 0) {
        $("#Btn").removeClass("disabledBtn").attr("disabled", false);
    } else {
        $("#Btn").addClass("disabledBtn").attr("disabled", "disabled");
    }
}
enableBtn();

&lt;table id="myTbl"&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;input name="" type="checkbox" value="" id="allCheckboxes"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;input name="" type="checkbox" value=""&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;input name="" type="checkbox" value=""&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;input name="" type="button" id="Btn"&gt;
</code></pre>

<p>I need help re-writing the function where the <code>#allCheckboxes</code> check-box is in one table and the rest are in another table:</p>

<pre><code>&lt;table id="myTbl1"&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;input name="" type="checkbox" value="" id="allCheckboxes"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;table id="myTbl2"&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;input name="" type="checkbox" value=""&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;input name="" type="checkbox" value=""&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;input name="" type="button" id="Btn"&gt;
</code></pre>

<p>Please note that unless ALL checkboxes are selected, the top one won't be selected. Ex. If all are selected and then one of them is unchecked, the top one would get unchecked too.</p>
