Filter on HTML table using jQuery I am adding some check box filters on a HTML table, based on whether a check box is checked or not, and I am toggling rows.  Is there anyway I could improve this code?  There is no issue with it at the moment I could think of e.g. performance wise, but maybe someone could help me with decreasing number of lines.

HTML

&lt;div id="RMbody" class="panel"&gt;
        &lt;div class="someRow" style="width: 100%"&gt;
                &lt;asp:CheckBox ID="cbIncludeOpen" runat="server" ClientIDMode="Static" Checked="true" onclick="RMToggle()" /&gt;
                &lt;asp:CheckBox ID="cbIncludeNew" runat="server" ClientIDMode="Static" onclick="RMToggle()" /&gt;
                &lt;asp:CheckBox ID="cbIncludeClosed" runat="server" ClientIDMode="Static" onclick="RMToggle()" /&gt;
                &lt;asp:CheckBox ID="cbIncludeRejected" runat="server" ClientIDMode="Static" onclick="RMToggle()" /&gt;
            &lt;/div&gt;
    &lt;table id="table1" class="dmctable"&gt;
        &lt;tr data-id="Open"&gt;&lt;/tr&gt;
        &lt;tr data-id="Rejected"&gt;&lt;/tr&gt;
        &lt;tr data-id="New"&gt;&lt;/tr&gt;
        &lt;tr data-id="Open"&gt;&lt;/tr&gt;
        &lt;tr data-id="Closed"&gt;&lt;/tr&gt;
        &lt;tr data-id="Open"&gt;&lt;/tr&gt;
        &lt;tr data-id="New"&gt;&lt;/tr&gt;
        &lt;tr data-id="Open"&gt;&lt;/tr&gt;
    &lt;/table&gt;
&lt;/div&gt;


JS

function RMToggle() {
    var o = $("#cbIncludeOpen").is(':checked');
    var n = $("#cbIncludeNew").is(':checked');
    var c = $("#cbIncludeClosed").is(':checked');
    var r = $("#cbIncludeRejected").is(':checked');

    if (o) { $('#table1 tr[data-id="Open"]').show(); }
    else { $('#table1 tr[data-id="Open"]').hide(); }

    if (n) { $('#table1 tr[data-id="New"]').show(); }
    else { $('#table1 tr[data-id="New"]').hide(); }

    if (c) { $('#table1 tr[data-id="Closed"]').show(); }
    else { $('#table1 tr[data-id="Closed"]').hide(); }

    if (r) { $('#table1 tr[data-id="Rejected"]').show(); }
    else { $('#table1 tr[data-id="Rejected"]').hide(); }
}
Since you are executing the RMToggle function whenever a checkbox is selected, extend it a little by passing in the IDs too. (I've changed the IDs as well):

&lt;div class="someRow" style="width: 100%"&gt;
    &lt;asp:CheckBox ID="Open" runat="server" ClientIDMode="Static" Checked="true" onclick="RMToggle(this)" /&gt;
    &lt;asp:CheckBox ID="New" runat="server" ClientIDMode="Static" onclick="RMToggle(this)" /&gt;
    &lt;asp:CheckBox ID="Closed" runat="server" ClientIDMode="Static" onclick="RMToggle(this)" /&gt;
    &lt;asp:CheckBox ID="Rejected" runat="server" ClientIDMode="Static" onclick="RMToggle(this)" /&gt;
&lt;/div&gt;


Now, moving to the toggle function:

function RMToggle( elm ) { // elm = element
    var ischecked = elm.checked,
        $target = $('#table1 tr[data-id="' + elm.id + '"]');
    $target.toggle( ischecked );
}