So after some thought, I think click event is more user friendly on a touch screen so I changed my code to swap letters on a click event instead that should work on every device.
$('.letter').on('click', function(e) {
if(b !=''){
a=$(this).html();
idNumb2 = $(this).attr('id');
idNumb2="#"+idNumb2;
if(idNumb !='' && idNumb !='undefined'){
$(idNumb).css("background-color", "#fff");
$(this).html(b);
$(idNumb).html(a);
checkWords();
}
a='';
b='';
idNumb='';
idNumb2='';
}
else{
b=$(this).html();
idNumb = $(this).attr('id');
idNumb="#"+idNumb;
$(idNumb).css("background-color", "#a5b06b");
}
});
I just added an integer id to each td and compare its html with this html on each click and change them or swap the html. This way works for me so I thought I would share my solution. Please comment if this is a bad way of doing it or if you can suggest a faster way.