【问题标题】:html protect th cells in a tablehtml 保护表格中的单元格
【发布时间】:2018-12-21 23:51:25
【问题描述】:

我正在尝试禁用 html 表格中的单元格以避免任何点击问题,但似乎禁用的属性对此不可用。

点击时focusout() 效果不佳,因此我寻求帮助以找到更好的解决方案。

【问题讨论】:

  • 默认情况下单击 th 不会执行任何操作。你试图阻止什么具体行动?您可以发布您的代码示例吗?
  • 什么意思?防止复制/粘贴?还是什么?

标签: html html-table cell


【解决方案1】:

如果您想阻止选择文本,请使用 CSS 属性 user-select: none

.noselect{
-webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Safari */
     -khtml-user-select: none; /* Konqueror HTML */
       -moz-user-select: none; /* Firefox */
        -ms-user-select: none; /* Internet Explorer/Edge */
            user-select: none; 
}
th{
 border: 1px solid gray;
}
<table>
<tr>
<th class="noselect">You can't select this</th>
<th>You can select this</th>
</tr>
</table>

【讨论】:

  • 这正是我想要的。现在我有了解决方案
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-10-07
  • 1970-01-01
  • 2017-05-27
  • 1970-01-01
  • 1970-01-01
  • 2019-06-22
  • 2021-08-26
相关资源
最近更新 更多