I want to collect all data from <td>'s
in a certain row. I have limited knowledge about jQuery
so I try to work myself through from the more general thing to what I exactly need.
For now I have this simple Example to illustrate what I mean. I create a table dynamically, according to a data from a database so one row may contain from 1 to many <td>..</td>
and in each <td>
I have an <input../>
control that holds some value. The ultimate goal is to be able to let the user edit a given row and then to Update (collect the values from all inputs and send them to the server) the edited data.
As you can see in my JsFiddle
example I figured out how to collect all the data using $('td').each(function()
but of course this is not what I want. I want only the data from which the getData()
function was called. Which leads to the first problem that I can't resolve (at least in a proper way).
What I know is that if nothing else I can give each <tr>
some unique id
so I can easily select it with jQuery
. However since I'm calling the function on click event from anchor inside a <td>
of the same row I'm pretty sure that there should be a way to determine the row without giving it unique id
and passing it as argument to the getData()
function but I couldn't find a way to do it. So is it really possible to determine the row without using special identifier and if so could you help me with the code for the jQuery
function to select the row for/from which the getData()
funciton was called?