As for the first, you can change that to:
Code:
for(var i = 1; i <= 5; ++i){
$("#image" + i).click(function(){
shiftH();
doThis(i);
});
$(document).bind('keydown', '' + i + '', function(){
$("#image" + i).click();
});
}
For the second, I guess you have two options.
I would use:
Code:
switch(n){
case '1':
rr = 'A';
break;
case '2':
rr = 'B';
break;
case '3':
rr = 'C';
break;
case '4':
rr = 'D';
break;
case '5':
rr = 'E';
break;
case '6':
rr = 'F';
break;
}
But a second, less preferred option would be:
Code:
var conditions = [['1', 'A'], ['2', 'B'], ['3', 'C'], ['4', 'D'], ['5', 'E'], ['6', 'F']];
for(var x in conditions){
if(n == conditions[x][0]){
rr = conditions[x][1];
}
}
Bookmarks