Firefox上的奇怪蓝色边框

时间:2012-02-26 09:08:45

标签: javascript jquery css firefox

请看一下这段代码

http://www.jsfiddle.net/tt13/5CxPr/21

在Firefox上,当您按 ctrl 按钮选择多行时会显示奇怪的蓝色边框,但在Chrome上却没有。

enter image description here

使用最新的Firefox 10.0.2。

这与浏览器有关吗?

3 个答案:

答案 0 :(得分:9)

这是由于选择了文本 - 本机浏览器行为。

您可以使用 SHIFT 键代替 CTRL 在Chrome中观察同样的问题。

要解决此问题,您只需在用户单击要选择的单元格后立即清除选择:

$(".subject").live('click',function(event) {
    if(event.ctrlKey) {
          $(this).toggleClass('selected');  
    } else {
          $(".subject").removeClass("selected");
          $(this).addClass("selected");           
    }
    if (document.selection)
        document.selection.empty();
    else if (window.getSelection)
        window.getSelection().removeAllRanges();
});

Updated fiddle

答案 1 :(得分:8)

尝试将CS​​S属性-moz-user-select设置为表以禁用默认选择行为:

table { -moz-user-select: none; }

MDN

答案 2 :(得分:3)

如果您准备在单元格中添加额外元素以允许文本仍可选择,则适用于当前版本的Firefox 20.0.1。

td { -moz-user-select: -moz-none }
td * { -moz-user-select: text }

http://jsfiddle.net/nukj7/

相关问题