我相信可以将一个DOM对象数组传递给jQuery的选择器,以便您可以同时处理多个对象。我试着这样做如下,但不能让它出于某种原因...将数组传递给jQuery Selector
$(Sel).animate({
backgroundColor: "#FF0000"
}, 250, 'linear', function() {
$(this).animate({
backgroundColor: "#FFFFFF"
}, 250, 'linear');
});
它实际上是有可能做到这一点还是我找错了树?
我把this jsFiddle放在一起测试一下。其目的是为预订系统选择半小时的插槽,因此我需要在下一行操作“this”和下面的单元格。
任何意见不胜感激。从小提琴
代码:
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();
[根据文档(http://api.jquery.com/jQuery/# jQuery1),它有可能:*“'jQuery(elementArray)':一个包含一组DOM元素的数组来包装在一个jQuery对象中。”*什么是'Sel'? *编辑:* nvm,没有看小提琴。 – 2012-08-13 15:41:15