JSFiddle - React, Tailwind, and code Playground
by ianlunn
HTML
<a href="#">Touch me</a>
CSS
a{
background: blue;
color: white;
height: 50px;
}
.touching{
background: red;
}
JavaScript
$(document).ready(function(){
$("a").on("touchstart touchend", function(e){
e.preventDefault(); //stops the link from going to another page
switch(e.originalEvent.type){
case "touchstart":
$("a").addClass("touching");
break;
case "touchend":
$("a").removeClass("touching");
break;
}
})
});