title: Calling a jQuery function from onclick event
body: <p>Due to some bizarre requirements and the way jQuery is implemented in our application, I have to call a jQuery function through a checkbox onclick event.  </p>
  
  <p>Below is a perfectly good implementation of the function being triggered via div ID. However, this same code will not work in my application.</p>
  
  <p>In my application, I am using jQuery version 1.7.1. I am not getting any errors, the function simply does not trigger. I'm using Chrome to debug. When I try to invoke it in onclick it responds, but throws back <code>undefined</code>.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;div id="dialog-confirm" title="Select Options"&gt;
      &lt;!--I need to call function in onclick event for checkbox below--&gt;
      &lt;input type="checkbox" id="chkall" /&gt; Check/Uncheck
      &lt;br /&gt;&lt;br /&gt;
  
      &lt;input type="checkbox" /&gt;Option 1&lt;br /&gt;
      &lt;input type="checkbox" /&gt;Option 2&lt;br /&gt;
      &lt;input type="checkbox" /&gt;Option 3&lt;br /&gt;
      &lt;input type="checkbox" /&gt;Option 4&lt;br /&gt;
      &lt;input type="checkbox" /&gt;Option 5&lt;br /&gt;
      &lt;input type="checkbox" /&gt;Option 6&lt;br /&gt;
      &lt;input type="checkbox" /&gt;Option 7
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>$(function() {
      $( "#dialog-confirm" ).dialog({
           resizable: false,
           height:350,
           modal: true,
           buttons: {
              "Go": function() {
                  $( this ).dialog( "close" );
              },
              Cancel: function() {
                  $( this ).dialog( "close" );
              }
          }
      });
  });
  
  $(document).ready(function(){ 
      $('#chkall').click(function() {
          // this is the function I need to call
          var opt = $(this).parent().find('input[type=checkbox]');
          opt.prop('checked', $(this).is(':checked') ? true : false);
      });     
  });
  </code></pre>
  
  <p><strong>Finally, Fiddle link</strong></p>
  
  <p><a href="http://jsfiddle.net/uxRGB/1/" rel="nofollow">http://jsfiddle.net/uxRGB/1/</a></p>