I have a table as shown below. Upon click on the edit I want to have the value of the first TD, i.e date, how can I do that, even with the second row?
<table id="foo" border="1px">
<tr>
<td rowspan='3' id="date">
Monday5 </td>
<td id="Name">
Jim
<a href="#" class="edit">
edit
</a>
</td>
</tr>
<tr>
<td id="Name">
Remy
<a href="#" class="edit">
edit</a>
</td>
</tr>
</table>
first of all you should fix your html code, as the
idattribute is unique. I suggest you use the class attribute:in the javascript code, I first check if there’s a date in the current row, if not, get the first prev. row containing a date:
see a working demo at: http://jsfiddle.net/roberkules/WwZPY/
sidenote: i noticed that you used uppercase and lowercase names for classes. I suggest to be more consistent and name them always upper or lowercase. and css classes are case sensitive, so in order to eliminate another error source, be consistent.