views:

35

answers:

1

Hi, I have been trying to use Prototype to do some DOM manipulation, but I am not able to find much help on a certain selector.

I have a table with many rows and each of these rows has 4 columns, with each having a different class name. Some of the cells might be empty, i.e., they do not have a class, in a particular row.

Now, when the user clicks on a cell in a particular row, I want the control to be transferred to the next cell of the same class, wherever that might be in the succeeding rows, if one exists.

Is it possible to do this using the Prototype library?

+1  A: 

.next()

Lets you get the next sibling

To get the next row you'd do .up().next();

Dan Heberden
Hi Dan. Thanks for the reply. I tried it out, and it works if the next row has a cell of that class. However, in the case that the next row does not have that cell with the required class, can I specify a condition in the selector, which keeps looking, till a cell is found? Thanks
Gunner4Life
Um, did ya check out the link? .next('.yourClass') will do just that. But read the documentation for it a bit to see what else it'll do..
Dan Heberden
Yes, got it to what I want with a bit of tweaking. Thanks!
Gunner4Life