需要帮助查找脚本中阻止文本选择的内容

时间:2014-09-10 13:12:47

标签: jquery html5-canvas particles

我正在使用以下可在此处看到的mobile-me脚本:

http://lokeshdhakar.com/projects/mobileme-particles/

我注意到它阻止了我在网站上选择文字的能力。例如,如果您使用鼠标在页面的页脚选择“创建者:lokesh dhakar”,则无法完成。

这是github存储库:

https://github.com/lokesh/mobileme-particles

我需要帮助找到阻止文本在此项目中被选中的内容。非常感谢任何帮助。

1 个答案:

答案 0 :(得分:2)

我将以智慧的话开头:

  

禁用文字选择很糟糕。不要使用它。

来自http://api.jqueryui.com/disableselection/

.disableSelection()

否则,您可以更改文本选择的背景以匹配其他背景

::selection {
  background: #ffb7b7; 
}

或来自:How to disable text selection using jQuery?

(function($){
  $.fn.disableSelection = function() {
    return this
             .attr('unselectable', 'on')
             .css('user-select', 'none')
             .on('selectstart', false);
  };
})(jQuery);

编辑:(来自我和Presto)补充 Modernizr.addTest("userselect",function(){ return Modernizr.testAllProps("user-select"); });到js文件,我现在可以选择文本:)

相关问题