I have a 5 x 5 table. Each cell is an asp.net textbox.
I want to get al the 5 textbox values of the last row with a non empty textbox.
For example:

This should get HELL O MY FRIE ND
But I get all the values BUT the last (ND). I don’t know why. Here’s my code:
// RIGHT HERE, $(this) referes to the whole table
$(this).find('input[value!=""]')
// I get the last edited textbox
.last()
// Go up to the parent <td>
.parent('td')
.siblings('td')
// I get all my brothers of type input
.children(':input')
.each(function () {
alert($(this).val());
});
I am doing something wrong but what?
thank you.
The problem lies when you call
.siblings()– that returns all other<td>elements that has the same parent as your currently selected<td>element. The problem can be solved by traversing up another step in the DOM and then selecting the children as has been shown by @Adrian, @Quintin Robinson, @Sushanth –, and @wirey.I figured that I would post an answer so you would have an explanation since all other answers solved your problem but didn’t explain what was wrong. And now here is how I would change your code 🙂