I have an ajax call attached to a click event for pic inside a table row. Once the click is clicked and the click event starts, I need to grab the first and second td elements from this line. I am new to jQuery, so I have my last attempt (not working ..). The variables firstName and lastName end as undefined after these lines are executed
$('.checkErrors').click(function () { var firstName = $(this).parent('tr td:first-child').val(); var lastName = $(this).parent('tr td:nth-child(2)').val(); $.ajax({ type: 'GET', url: '@Url.Action("GetErrors","AgentTransmission")', data: { term: $(this).attr('id') }, . . }); });
Here is an example table row. The image in the last td element contains the .click event. I would like to take the first two, which contain the text "phinneas" and "ferbseven".
<tr> <td> phinneas </td> <td> ferbseven </td> <td nowrap> 7735 </td> <td> Agent </td> <td> SAF   07070900 </td> <td> 6/5/2013 10:35:38 AM </td> <td> DANTAK </td> <td class="errorPlus"> Error </td> <td> <a href="/AgentTransmission/Details/2358">Details</a> <span> | </span> <a href="/AgentTransmission/Edit/2358">Edit</a> </td> <td align=center id=2358> <img src="/Content/images/magnify.gif" class="checkErrors" id=2358 alt="Program Details" /> </td> </tr>
NealR source share