tags:

views:

38

answers:

3

I have a table with a thead and couple of tr in a tbody

When I click on a cell in a tr, i want to traverse to the text of the cell that is before it

For eg if i clicked on Cell 3 of Row 3, i want to find the text of Cell2 of Row 3

How i do it?

Edit: I cancelled my edit. I will open a new question to avoid confusiing user who helping me.

+1  A: 
$("td.my_class").click(function() {
    var previous_sibling = $(this).prev();
    // Do something
});
Cide
thank you very much
A: 

Something like:

$("td").click(function(){
  text = $(this).prev("td").text();
  alert(text);
});
Jonathan Sampson
A: 

Use,

document.activeElement.previousSibling.innerHTML
adatapost
Note, the author tagged this question with 'jQuery'.
Jonathan Sampson