I'm writing a script to highlight table cells across multiple tables, in a calendar. The days to be highlighted have the class "available". This is the jQuery code currently:
$(document).ready(function(){
$("td.available").mouseenter(function() {
$(this).addClass("highlight");
$(this).next().addClass("highlight");
});
$("td.available").mouseleave(function() {
$(this).removeClass("highlight");
$(this).next().removeClass("highlight");
})
});
However, highlighting only works within the table containing the element being hovered over. I assume .next() isn't operating over the set returned by $("td.available")
, but over the raw DOM.
What function should i be using to operate over the set properly?
Edit: What I want to happen is for the adjacent cell to be highlighted as well. This could be expanded so the next 7 cells are highlighted as well, for example.
If I hover over the cell containing 31, the other cells to highlight are going to be in another table, containing the next month. I'm guessing I need to use some variety of "each" to get a set of td elements.