Can I make an if statement that is variable?
I have the following lines of code:
- $(".ErrorCode").click(function () {
- ErrorCode = $(this).val();
- if ( $(this).attr('id') == 'e1' ) {
- $('.error1').show();}
- else if ( $(this).attr('id') == 'e2' ) {
- $('.error2').show();}
It goes on to like 300 errors.
Can I make one simple code that says something like
- if ( $(this).attr('id') == 'e(whatever number)' ) {
- $('.error(whatever number)').show();}
So it's not like 600 lines?