title: Run a function when submitting a form failing
body: <p>I have the following set of checkboxes in a webpage</p>
  
  <pre><code>&lt;form id="tagselect" action=""&gt;
  &lt;input id="tag" type="checkbox" value="*"&gt;Show all&lt;/input&gt;
  &lt;input id="tag" type="checkbox" value=".Name1"&gt;Name1&lt;/input&gt;
  &lt;input id="tag" type="checkbox" value=".Name2"&gt;Name2&lt;/input&gt;
  &lt;input type="button" value="submit"&gt;&lt;/input&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I want to make it so a function runs either when the submit button is pressed, or remove the submit button and make it so it runs any time any checkbox is changed.</p>
  
  <p>I have tried pretty much every different way to achieve this as recommended in this old question here:
  <a href="https://stackoverflow.com/questions/10549205/run-a-function-after-checkbox-checked-and-pushed-submit-button-with-jquery">run a function after checkbox checked and pushed submit button with jquery</a>
  along with a few different tweaks of them just o a random hunch, and I cannot get ANYTHING to happen when a checkbox is checked except the checkmark appearing. I tested with a simple:</p>
  
  <pre><code>alert("This is working");
  </code></pre>
  
  <p>and it worked fine when it was just running in a script block with no conditions, but as soon as i put it in the middle of some script to make it run when a checkbox is checked or a button is pushed, the alert won't appear no matter what.</p>
  
  <p>A few of the things I've tried:</p>
  
  <pre><code>&lt;script&gt;
  $("input[id='tag']:checked").each(
      function() {
          alert("This is working");
      }
  );
  &lt;/script&gt;
  </code></pre>
  
  <p>Attempt 2:</p>
  
  <pre><code>&lt;script&gt;
  $("input#tag :checked").each(
      function() {
          alert("This is working");
      }
  );  
  &lt;/script&gt;
  </code></pre>
  
  <p>Attempt 3:</p>
  
  <pre><code>&lt;script&gt;
  $('#tagselect').submit(function(){
  $('#tag:checked').each(function()
        {
           alert("This is working");
        })
   });
  &lt;/script&gt;
  </code></pre>
  
  <p>Attempt 4:</p>
  
  <pre><code>&lt;script&gt;
  $('input[value=submit]').on('click', myFunction);
  </code></pre>
  
  <p>Then this in either a new script block or the same script block(tried both):</p>
  
  <pre><code>function myFunction() {
  alert("This is working");
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I also tried that same myFunction, but with </p>
  
  <pre><code>onclick="myFunction()"
  </code></pre>
  
  <p>added to the submit button html</p>
  
  <p>Absolutely nothing visibly happened besides the button clicking or the checkboxes checking on any of these runs.</p>
  
  <p>I have also tried putting all the scripts together in the head, together in the body, separately around where they are going to be used, ad i have triple checked spelling and capitalization is consistent in the actual copies. I have removed the submit button and tried some of these without it. I have tried switching browsers in case it was a compatibility issue. I don't know enough about JS to even know where to start researching what I'm doing wrong. </p>