在要让文本不能被选中的TD内加入
onselectstart="return false" onselect="document.selection.empty()"
<table>
<tr><td onselectstart="return false" onselect="document.selection.empty()">宝宝(不能选)</td></tr>
<tr><td>宝宝(可以选)</td></tr>
onselectstart="return false" onselect="document.selection.empty()"
<table>
<tr><td onselectstart="return false" onselect="document.selection.empty()">宝宝(不能选)</td></tr>
<tr><td>宝宝(可以选)</td></tr>
</table>
本文介绍了一种在网页表格单元格中禁止文本被选中的方法,通过使用 onselectstart 和 onselect 事件来实现这一功能。这种方法适用于需要保护特定文本不被用户误操作的应用场景。
42





