Anfaenger hat click touchstart Problem

Der Klick wechselt die Buttonfarbe von grau nach rot oder von rot nach grau. Wenn ich dagegen den Browser auf Mobilsimulation stelle, dann wechselt das Script auf Touch von grau nach gelb, beim nächsten Touch auf rot und beim Nächsten auf Grau. Bei Touch soll aber gelb und grau hin und her wechseln. Ich bin verzweifelt, ich hoffe ihr könnt mir helfen.
Kommentar abgeben zu diesen Beitrag/Code ?
Dann hier klicken

Der hier verwendete Code

<!DOCTYPE html> <html lang="de"> <head> <title>AB10 Aufgabe 1</title> <meta charset="utf-8"> <style> body { text-align: center; } input { background-color: grey; width: 80%; height: 100px; } .grey {background-color: grey;} .red {background-color: red;} .green {background-color: green;} .blue {background-color: blue;} .orange {background-color: .orange;} .magenta {background-color: magenta;} .cyan {background-color: cyan;} .beige {background-color: gold;} .bisque {background-color: bisque;} .lime {background-color: lime;} .skyblue {background-color: skyblue;} .blueviolet {background-color: blueviolet;} .brown {background-color: brown;} .yellow {background-color: yellow;} .mintcream {background-color: mintcream;} .olive {background-color: olive;} </style> <script src="/js_webseite/jquery.js"></script> </head> <body> <input type="button" class="grey" name="but0" value="Tap or Click me" id="select0" /> <input type="button" class="grey" name="but1" value="Tap or Click me" id="select1" /> <input type="button" class="grey" name="but2" value="Tap or Click me" id="select2" /> <script> $(":button").on('click', function (e) { weiter('false',$(this)); }); $(":button").on('touchstart', function () { weiter('true',$(this)); if(event.handled === false) return event.stopPropagation(); event.preventDefault(); event.handled = true; }); function weiter(x,y){ var gValue = y.attr('class'); if(x=='false'){ var col='yellow'; }else{ var col='red'; } console.log(col) if (gValue == 'grey') { y.removeClass("grey"); y.addClass(col); } else { y.removeClass(col); y.addClass("grey"); } } </script> </body> </html>