title: How to create multiple checkbox handlers in jQuery?
body: <p>I have these 2 checkboxes:</p>
  
  <pre><code>&lt;form action=""&gt;
      &lt;input id="bikeCheckbox" type="checkbox" name="bikeCheckbox" value="Bike"&gt;I have a bike&lt;br&gt;
      &lt;input id="carCheckbox" type="checkbox" name="carCheckbox" value="Car"&gt;I have a car
  &lt;/form&gt;
  </code></pre>
  
  <p>The events for each checkbox:</p>
  
  <pre><code>jQuery(function () {
  $("#carCheckbox").click(function () {
      if($("#carCheckbox").is(":checked")) {
          alert("it works");
      }
  })
  });
  
  jQuery(function () {
  $("#carCheckbox").click(function () {
      if($("#bikeCheckbox").is(":checked")) {
          alert("it works");
      }
  })
  });
  </code></pre>
  
  <p>Now what I want to do is create a <code>for</code> or some kind of loop to create event handlers for multiple checkboxes. So far I am stuck at this code:</p>
  
  <pre><code>jQuery(function () {
  var infoArray = ["car", "bike"];
  
  for(var i = 0; i &lt; infoArray.length; i++) {
      var id = "#" + infoArray[i] + "Checkbox";
  
      $(id).click(function () {
          var myCheckbox = "#" + infoArray[i] + "Checkbox;
          if($(myCheckbox).is(":checked")) {
              alert("it works");
          }
      })
  }
  });
  </code></pre>
  
  <p>Any help is greatly appreciated.</p>