combine click and change for one execution

combine click and change for one execution

I need to execute the same code for both a link click and change event
  1. <img class="foo" name="54321" src="http://jsfiddle.net/img/logo.png" >
  2. <br><br>
  3. <select class="bar" name="12345" size="1">
  4.       <option  value="0">0</option>
  5.       <option  value="1">1</option>
  6. </select>​
  7. $(".foo").click(function() {
  8.   //same code
  9. }
  1. $(".bar").change(function() {
  2.   //same code
  3. }

  4. $('. foo , .bar').on('click change', function() {
  5.     alert ($(this).attr('name'));
  6. });​
If I click on the selectbox, I get the messagebox before I change the value.
Anybody an idea?