【发布时间】:2013-08-03 20:04:38
【问题描述】:
var flag=false;
$(document).live('mouseup', function () { flag = false; });
var colIndex; var lastRow;
$(document).on('mousedown', '.csstablelisttd', function (e) {
//This line gets the index of the first clicked row.
lastRow = $(this).closest("tr")[0].rowIndex;
var rowIndex = $(this).closest("tr").index();
colIndex = $(e.target).closest('td').index();
$(".csstdhighlight").removeClass("csstdhighlight");
if (colIndex == 0 || colIndex == 1) //)0 FOR FULL TIME CELL AND 1 FOR TIME SLOT CELL.
return;
if ($('#contentPlaceHolderMain_tableAppointment tr').eq(rowIndex).find('td').eq(colIndex).hasClass('csstdred') == false)
{
$('#contentPlaceHolderMain_tableAppointment tr').eq(rowIndex).find('td').eq(colIndex).addClass('csstdhighlight');
flag = true;
return false;
}
});
document.onmousemove = function () { return false; };
$(".csstablelisttd").live('mouseenter', function (e) {
// Compares with the last and next row index.
var currentRow = $(this).closest("tr")[0].rowIndex;
var currentColoumn = $(e.target).closest('td').index();
// cross row selection
if (lastRow == currentRow || lastRow == currentRow - 1 || lastRow == currentRow + 1)
{
lastRow = $(this).closest("tr")[0].rowIndex;
}
else
{
flag = false;
return;
}
// cross cell selection.
if (colIndex != currentColoumn)
{
flag = false;
return;
}
if (flag)
{
$('#contentPlaceHolderMain_tableAppointment tr').eq(currentRow).find('td').eq(currentColoumn).addClass('csstdhighlight');
e.preventDefault();
return false;
}
});
当我在表格上快速移动光标时,单元格选择停止。
在表格单元格上快速移动光标时,我应该怎么做才能防止选择停止。
我不想更改页面的 html。
该问题主要发生在 IE 7 中。
我已经处理了事件 mousedown, mouseenter on tr 类。
【问题讨论】:
-
快速浏览了一下。我的第一个猜测是,这与检查“加号或减号”一排的距离有关。希望这可以让您走上解决问题的道路。等我有时间再回头看看。
-
travJenkins 检查了 andyb 的答案,但是当我只单击单元格然后突出显示单元格选择时,我注意到了一些错误。另一点我注意到发生了交叉选择。当在桌子上移动鼠标时。跨度>
标签: javascript jquery internet-explorer-7