我有 jQuery 代码:
$('td').hover(function () {
var t = $(this),
index = t.index(); // the position of the TD in the row, so you can find the one below it
t.addClass('hovered'); // apply hovered class to this TD...
t.nextAll(':lt(3)').addClass('hovered'); // ...and to the TD next to it...
t.closest('tr')
.nextAll(':lt(3)')
.find('td:eq(' + index + ')')
.addClass('hovered')
.nextAll(':lt(3)')
.addClass('hovered'); // ...and to the 2 below
}, function () {
// remove the hovered class when no longer hovering
$(this).closest('table').find('td').removeClass('hovered');
});
如何选择 4x4 单元格?不像演示那样 2x4 +2。