0

There is a small button that reveals some extra content when clicked. When I click fast or more than once the content that shows up is marked like it is selected:

enter image description here

This selection disappears when the animation of jquery show effect is finished. The black arrow points to the button.

Any idea why there is this selection and how to avoid it?

DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601

3 Answers3

1

When you're clicking fast you're probably moving your mouse a bit, which makes you select items. Try using

document.selection.empty();

and (doesn't work in all browsers)

window.getSelection().removeAllRanges();

to clear the selection.

Source: Clear a selection in Firefox

Community
  • 1
  • 1
Ratzor
  • 307
  • 3
  • 15
0

You could also set the highlight-color to be the same as the background of the container, then if it does get selected you won't actually notice..?

danwellman
  • 9,068
  • 8
  • 60
  • 88
0

You could also use CSS to make buttons not be selectable, which would disable the browsers' text selection. I'm not sure exactly what your button css style looks like but something like this should work:

button {
    ...
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
Kristoffer
  • 362
  • 2
  • 10