更TR我有jQuery代碼:如何選擇HTML表格
$('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像演示。
你應該看看tableHover插件,這真是太棒了:http://p.sohei.org/stuff/jquery/tablehover/demo/demo.html – mattytommo