Can I make an if statement that is variable?

Can I make an if statement that is variable?

I have the following lines of code:
  1. $(".ErrorCode").click(function () {
  2.       ErrorCode = $(this).val();
  3.       if ( $(this).attr('id') == 'e1' ) {
  4.             $('.error1').show();}
  5.       else if ( $(this).attr('id') == 'e2' ) {
  6.             $('.error2').show();}
It goes on to like 300 errors.

Can I make one simple code that says something like 
  1. if ( $(this).attr('id') == 'e(whatever number)' ) {
  2. $('.error(whatever number)').show();}
So it's not like 600 lines?