What is the best way to prevent highlighting of text when clicking on its containing div in javascript?

前端 未结 4 1684
南方客
南方客 2020-12-05 15:51

I am building a menu in HTML/CSS/JS and I need a way to prevent the text in the menu from being highlighted when double-clicked on. I need a way to pass the id\'s of several

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 16:11

    You could use this CSS to simply hide the selection color (not supported by IE):

    #id::-moz-selection {
      background: transparent;
    }
    
    #id::selection {
      background: transparent;
    }
    

提交回复
热议问题