在做div的點擊計數事件時,遇到一個小問題。
因為div里面有文字,所以當點擊多次時,特別是鼠標點的比較快的時候,文字會被選中。
查了下,用css和javascript可以實現禁止選擇。
css代碼:
/* css style: */
html,body{
-moz-user-select: none;
-khtml-user-select: none;
user-select: none;
}
html代碼
說明:
<div unselectable="on"
onselectstart="return false;"
style="-moz-user-select:none;"> some text</div>
unselectable針對IE
onselectstart針對Chrome、Safari
-moz-user-select是firefox專有的
PS:我的淘寶店鋪新開業,經營各種桌游,棋牌,希望大伙兒能來看看!http://201314yes.taobao.com/