在做div的点击计数事件时,遇到一个小问题。

因为div里面有文字,所以当点击多次时,特别是鼠标点的比较快的时候,文字会被选中。

查了下,用css和javascript可以实现禁止选择。

css代码:

/* css style: */
html,body{
-moz-user-select: none;
-khtml-user-select: none;
user-select: none;
}

 

<div unselectable="on" onselectstart="return false;" style="-moz-user-select:none;"> some text </div>

 

说明:
unselectable针对IE
onselectstart针对Chrome、Safari
-moz-user-select是firefox专有的 

 

相关文章:

  • 2022-01-24
  • 2021-12-25
  • 2022-02-03
  • 2021-09-15
  • 2021-05-08
  • 2022-01-05
猜你喜欢
  • 2021-09-27
  • 2021-10-26
  • 2022-03-05
  • 2021-10-07
  • 2022-12-23
  • 2021-09-18
相关资源
相似解决方案