複数のオブジェクトを同時に操作できるように、DOM オブジェクトの配列を jQuery のセレクターに渡すことは可能だと思います。以下のようにしてみましたが、なぜかうまくいきません...
$(Sel).animate({
backgroundColor: "#FF0000"
}, 250, 'linear', function() {
$(this).animate({
backgroundColor: "#FFFFFF"
}, 250, 'linear');
});
実際にこれを行うことは可能ですか、それとも間違ったツリーを吠えていますか?
このjsFiddleをまとめてテストしました。目的は、30 分のスロットが選択される予約システムを作成することなので、「これ」と次の行の下のセルを操作する必要があります。
アドバイスをいただければ幸いです。
フィドルからのコード:
function HighlightCells() {
$('table#Calendar tbody tr td:not(".TimeCell")').live('mouseenter', function() {
var Sel = new Array();
Sel[1] = $(this);
// Count number of previous TDs. Resut is base 0
var NumIn = $(this).prevAll('td').length;
// Increment count to compensate for nth-child being base 1
NumIn++;
var NextRow = $(this).closest('tr').next('tr');
Sel[2] = $(NextRow).children("td:nth-child(" + NumIn + ")");
// Animate the cell background colour red to white
$(Sel).animate({
backgroundColor: "#FF0000"
}, 250, 'linear', function() {
$(this).animate({
backgroundColor: "#FFFFFF"
}, 250, 'linear');
});
$('table#Calendar tbody td').live('mouseleave', function() {
$(this).text("");
});
});
}
HighlightCells();