Reputation: 11
I'd like to highlight an entire div when the user touches or selects the text contained in the div. I'm able to highlight the text only when it is contained in a span with a javascript function, but when I try to apply the function to the entire div it does not work. In my research I've seen many people remove a highlight with -webkit-tap-highlight-color:, is there a way to use this or another css style to add a highlight to an item that is not a link?
The script I am using:
function changeColor(e,color){ element = e; oldColor = element.currentStyle.background; element.style.background = color; }
Upvotes: 1
Views: 1351
Reputation: 39
I was facing the same issue on a mobile app and I have resolved issues with the below code.
*:not(a) {
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
Upvotes: 1
Reputation: 8535
If you attach a click handler to the div Safari would highlight the div on click.
An Example is here http://jsbin.com/awejo3/4
Got the information from this question: Iphone darkens div on click
Upvotes: 1