title: How to attach an event handler with eventData and a named function?
body: <p>I have a page with elements that have the ID "rec-0", "rec-1", to "rec-n", and I'm trying to figure out how to attach an event to them. They are input elements that are children of td elements. </p>
  
  <pre><code>&lt;td&gt;&lt;input type="checkbox" id="rec-0" /&gt;&lt;/td&gt;
  </code></pre>
  
  <p>I tried to attach an event handler to all of the elements with this: </p>
  
  <pre><code>$("td &gt; input").change({ elem:this }, recipe_checkbox_clicked); 
  </code></pre>
  
  <p>but within the <code>recipe_checkbox_clicked()</code> function I get <code>Uncaught TypeError: Object #&lt;Object&gt; has no method 'prop'</code>. This is the recipe_checkbox_clicked function: </p>
  
  <pre><code>function recipe_checkbox_clicked(elem) { 
      if (elem.prop('checked')) $("#modify-recipe").show(); 
      else $("#modify-recipe").hide(); 
  }
  </code></pre>
  
  <p>If I copy the function's code into an anonymous function, with a slight modification it works as expected. Here's the modified code: </p>
  
  <pre><code>$("td &gt; input").change( function() { 
      if ($(this).prop('checked')) $("#modify-recipe").show(); 
      else $("#modify-recipe").hide(); 
  }); 
  </code></pre>
  
  <p>I can leave as is, but I prefer to not use anonymous functions. Is there a way to accomplish what I'm trying without using them? </p>
  
  <hr>
  
  <p>With Adil and Felix's help and suggestions, I've gotten the behavior I wanted with the following code!</p>
  
  <pre><code>function recipe_checkbox_clicked() { 
      if ($(this).prop('checked')) $("#modify-recipe").show(); 
  
      var any_checked = false; 
      $("td &gt; input").each(function() { 
          if($(this).prop('checked')) {
              any_checked = true; 
              return false; 
          }
      }); 
      if (!any_checked) $("#modify-recipe").hide(); 
  }
  </code></pre>
  
  <p>And the selector that attaches this function:</p>
  
  <pre><code>$("td &gt; input").change(recipe_checkbox_clicked);
  </code></pre>
  
  <p>Thank you so much! I have burned hours trying to figure out how to do this. </p>