Hi! I've got a table with multiple rows which I'd like to traverse in a special way - here's the html (for better reading, I just included two rows, these rows are duplicated with different values):
<tbody> <tr class="pricing"> <td>Example A</td> <td><span class="price">1,20</span> €</td> <td><span class="price">2,40</span> €</td> </tr> <tr class="calc"> <td>Calculator</td> <td><input /><span class="result">0,00</span> €</td> <td><input /><span class="result">0,00</span> €</td> </tr> </tbody> What I'd like to do: If an input filed is focussed, a price should be calculated. To keep the script as efficient as possible, I want to travel up from the input field to the cell above it (i.e. one row up, second or third cell in that row). My problem is: How can I traverse the DOM in this way? I imagine the following: The script should "know" where the starting point was (second or third cell in row) and then get the corresponding cell. I'm sure this is possible, but I have no idea how to achieve it. If I get the DOM traversing right, I want to get the value of span.price to calculate the input with it & update the result in - yes, span.result ;-) I'm sure this is a pretty easy thing to achieve for people how know jQuery well - I unfortunately don't (yet!). Could someone please explain this? Thanks for your effort! Markus