开发者

iphone- Highlighting div on tap that isn't a link

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; }


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


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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜