prevent text from being selected

Discussion in 'JavaScript' started by bonecone, Apr 1, 2012.

  1. #1
    I retrieve a list of links from a database using ajax, then I assign them to the innerHTML property of a div whose display property is set to "none" Then I set the display property to "display" to get a drop-down listbox.

    The problem is the links in the list are all hilighted like they've been dragged over by a mouse.

    How do I prevent these links from highlighting?
     
    bonecone, Apr 1, 2012 IP
  2. rgba

    rgba Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can use CSS to disable text selection:

    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
     
    rgba, Apr 4, 2012 IP