views:

21

answers:

1

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

A: 

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: http://stackoverflow.com/questions/2355154

Shaji