Jquery - checkbox label click not working
<p><strong>Here is the HTML Sample dynamically generated from c#.net:-</strong></p>

<pre><code>&lt;ul class="multiselect-checkboxes clearfix horizontal" id="chkMC"&gt;&lt;li onclick="setMcCb(event);"&gt;&lt;span class="QRadio"&gt;&lt;input type="checkbox" name="ctl03$ctl05$CheckboxChoices0-931336440" id="ctl03_ctl05_CheckboxChoices0-931336440"&gt;&lt;label for="ctl03_ctl05_CheckboxChoices0-931336440"&gt;1-2 Years&lt;/label&gt;&lt;/span&gt;&lt;/li&gt;&lt;li onclick="setMcCb(event);"&gt;&lt;span class="QRadio"&gt;&lt;input type="checkbox" name="ctl03$ctl05$CheckboxChoices1-1671570667" id="ctl03_ctl05_CheckboxChoices1-1671570667"&gt;&lt;label for="ctl03_ctl05_CheckboxChoices1-1671570667"&gt;5-10 Years&lt;/label&gt;&lt;/span&gt;&lt;/li&gt;&lt;li onclick="setMcCb(event);"&gt;&lt;span class="QRadio"&gt;&lt;input type="checkbox" name="ctl03$ctl05$CheckboxChoices2679786207" id="ctl03_ctl05_CheckboxChoices2679786207"&gt;&lt;label for="ctl03_ctl05_CheckboxChoices2679786207"&gt;10-12 Years&lt;/label&gt;&lt;/span&gt;&lt;/li&gt;&lt;li onclick="setMcCb(event);"&gt;&lt;span class="QRadio"&gt;&lt;input type="checkbox" name="ctl03$ctl05$CheckboxChoices3-977631492" id="ctl03_ctl05_CheckboxChoices3-977631492"&gt;&lt;label for="ctl03_ctl05_CheckboxChoices3-977631492"&gt;12-15 Years&lt;/label&gt;&lt;/span&gt;&lt;/li&gt;&lt;li onclick="setMcCb(event);"&gt;&lt;span class="QRadio"&gt;&lt;input type="checkbox" name="ctl03$ctl05$CheckboxChoices41547758987" id="ctl03_ctl05_CheckboxChoices41547758987"&gt;&lt;label for="ctl03_ctl05_CheckboxChoices41547758987"&gt;15-20 Years&lt;/label&gt;&lt;/span&gt;&lt;/li&gt;&lt;li onclick="setMcCb(event);"&gt;&lt;span class="QRadio"&gt;&lt;input type="checkbox" name="ctl03$ctl05$CheckboxChoices5-1658326960" id="ctl03_ctl05_CheckboxChoices5-1658326960"&gt;&lt;label for="ctl03_ctl05_CheckboxChoices5-1658326960"&gt;20-21 Years&lt;/label&gt;&lt;/span&gt;&lt;/li&gt;&lt;li onclick="setMcCb(event);"&gt;&lt;span class="QRadio"&gt;&lt;input type="checkbox" name="ctl03$ctl05$CheckboxChoices6-100787876" id="ctl03_ctl05_CheckboxChoices6-100787876"&gt;&lt;label for="ctl03_ctl05_CheckboxChoices6-100787876"&gt;22-23 Years&lt;/label&gt;&lt;/span&gt;&lt;/li&gt;&lt;li onclick="setMcCb(event);"&gt;&lt;span class="QRadio"&gt;&lt;input type="checkbox" name="ctl03$ctl05$CheckboxChoices7122075492" id="ctl03_ctl05_CheckboxChoices7122075492"&gt;&lt;label for="ctl03_ctl05_CheckboxChoices7122075492"&gt;23-24 Years&lt;/label&gt;&lt;/span&gt;&lt;/li&gt;&lt;li onclick="setMcCb(event);"&gt;&lt;span class="QRadio"&gt;&lt;input type="checkbox" name="ctl03$ctl05$CheckboxChoices8-1742375481" id="ctl03_ctl05_CheckboxChoices8-1742375481"&gt;&lt;label for="ctl03_ctl05_CheckboxChoices8-1742375481"&gt;More than that&lt;/label&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="QRadio"&gt;&lt;input type="checkbox" name="ctl03$ctl05$CheckboxChoicesOther" id="ctl03_ctl05_CheckboxChoicesOther"&gt;&lt;label for="ctl03_ctl05_CheckboxChoicesOther"&gt;other&lt;/label&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;input type="text" style="width: 150px;" class="QTextBox" id="ctl03_ctl05_otherText" name="ctl03$ctl05$otherText"&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="QRadio"&gt;&lt;input type="checkbox" name="ctl03$ctl05$CheckboxChoicesNA" id="ctl03_ctl05_CheckboxChoicesNA"&gt;&lt;label for="ctl03_ctl05_CheckboxChoicesNA"&gt;plplpl&lt;/label&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;
</code></pre>

<p><strong>JS Method:-</strong></p>

<pre><code>function setMcCb(e) {  
                if (!e) var e = window.event;                             
                var tg = (window.event) ? e.srcElement : e.target;  //FF &amp; IE.
                var j$chk = j$(tg).closest('li').find(':checkbox');

                if ( j$chk[0] != tg)                        
                    j$chk.attr('checked', !j$chk.attr('checked'));
                }
</code></pre>

<p>*<strong><em>Purpose of the JS Method:-</em> I created this javascript when anyone clicks the checkbox, label or the li tag, the checkbox should toggle. *</strong></p>

<p>*<strong><em>My Problem:- When i click the label element, the js is not working. The toggle is not happening. Please help me refine the js code.  *</em></strong> </p>

<p><strong>I made it work the following code:-</strong></p>

<pre><code> if (!e) var e = window.event;                             
                    var tg = (window.event) ? e.srcElement : e.target;  //FF &amp; IE.                    
                    //Label click does not toggle the cbx with this JS, so the below processing is skipped by returning false.
                    if (tg.tagName.toUpperCase() == 'LABEL')
                        return false;

                    var j$chk = j$(tg).closest('li').find(':checkbox');
                    if ( j$chk[0] != tg){                        
                         if(j$chk.attr('checked'))
                            j$chk.removeAttr('checked');
                         else 
                            j$chk.attr('checked', 'checked');
                        }
</code></pre>
