gpt4 book ai didi

javascript - 当单元格进入编辑模式时,禁止单击除一个单元格(所选行中)之外的任何位置

转载 作者:行者123 更新时间:2023-12-02 15:20:32 26 4
gpt4 key购买 nike

如何禁用除连续一个单元格之外的所有网格单元上的点击?当单元格进入编辑模式时,我试图禁用对网格中任何单元格的单击。所以我尝试了:

$('#QCStatus tr td').bind('click',function() {
return false;
});

//QCStatus is the id of the grid

为了启用对正在编辑的同一行中的单元格的单击,我尝试了:

$('#QCStatus tr.selected-row td[aria-describedby="QCStatus_ActionIcons"]').bind('click',function() {
return true;
});

但这没有任何效果,因为第一个代码段禁用了点击。实现这一目标的正确方法是什么?

最佳答案

您可以在此处使用 :not() 排除所选行:

$('#QCStatus tr:not(.selected) td').on('click', function(e) {
$('pre').prepend('event :::: '+e.type+'\n');
return false;
});
.selected{background:yellow;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table id='QCStatus'>
<tr><td>click</td></tr>
<tr class='selected'><td>click</td></tr>
<tr><td>click</td></tr>
<tr><td>click</td></tr>
</table>

<pre></pre>

这将绑定(bind)对所有不是 tr.selected 子级的 td 的点击。

<小时/>

根据您的评论,您可以添加更多内容:

如何排除所选行中的 td td[aria-scribedby="QCStatus_ActionIcons"]

$('#QCStatus tr:not(.selected) td:not([aria-describedby="QCStatus_ActionIcons"])').on('click', function(e) {
$('pre').prepend('event :::: '+e.type+'\n');
return false;
});

关于javascript - 当单元格进入编辑模式时,禁止单击除一个单元格(所选行中)之外的任何位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34128328/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com