Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safari on the iPhone & iPad gives colour feedback on touch, I want to stop this

Clicking on an element which has a Javascript handler makes the element go have a 'grey overlay'. This is normally fine but I'm using event delegation to handle the touchdown events of many child elements. Because of the delegation the 'grey overlay' is appearing over the parent element and looks bad and confusing.

I could attach event handlers to the individual elements to avoid the problem but this would be computationally very wasteful. I'd rather have some webkit css property that I can override to turn it off. I already have visual feedback in my app so the 'grey overlay' is not needed.

Any ideas?

like image 742
Owen Avatar asked Oct 24 '25 15:10

Owen


2 Answers

-webkit-tap-highlight-color

To disable tap highlighting, set the alpha value to 0 (invisible)

like image 199
drawnonward Avatar answered Oct 27 '25 06:10

drawnonward


$('body').bind('touchstart', function(e){ e.preventDefault() })

like image 25
Owen Avatar answered Oct 27 '25 06:10

Owen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!