title: jQuery - Multiple Triggers for the Same Function
body: <p>I'm developing some jQuery, but I'm a beginner so it's a little bit bloated and not very elegant. Basically, I want a cookie value to be nullified when either one of two forms are submitted or their submit buttons are clicked. But I don't know how to consolidate the conditions of the function so that I only have to write out the function once, so the best I can do is this:</p>
  
  <pre><code>$('form#searchform-basic').submit(function() {
      $.cookie('tab_cookie', null);
  });
  $('form#searchform-basic a.search').click(function() {
      $.cookie('tab_cookie', null);
  });
  $('form#searchform-advanced').submit(function() {
      $.cookie('tab_cookie', null);
  });
  $('form#searchform-advanced input#search-button-submit').click(function() {
      $.cookie('tab_cookie', null);
  });
  </code></pre>
  
  <p>There's got to be a better way, right?</p>
  
  <p>And before anybody asks, yes, you would think that you'd only need to know when the forms are being submitted. But leaving out the click events means that the function doesn't run when the submit buttons are clicked. I don't know why it is like that, it just is.</p>