Tengo una tabla y sé cómo buscar siguiente y anterior TD
, pero ¿cómo hacerlo en el siguiente y anterior TR
?jQuery encuentra la misma td en prev. y la siguiente fila
012
345 <- example, I clicked on 4, it checks 3 and 5, but how to check on 0,1,2 and 6,7,8?
678
$(document).ready(function() {
$("td").click(function() {
var x = $(this).next().css('backgroundColor');
var y = $(this).prev().css('backgroundColor');
if (x == 'rgb(255, 0, 0)' || y == 'rgb(255, 0, 0)') {
return;
} else {
$(this).css('backgroundColor', 'red');
}
});
});
su html se trunca – DG3
no estoy seguro pero trate '$ (this) .parent() prev()' – MilkyWayJoe