jquery - Accessing various child elements of a table -


i trying access elements on same <tr> level seen below

<tr>   <td ><input type='text' value='{$result['name']}' name='itemname' /></td>   <td><input type='text' value='{$result['quantity']}' name='itemquantity' /></td>   <td><input type='text' value='{$result['cost']}' name='itemprice' /></td>   <td><input type='submit' name='submit' value='submit'/></td> </tr> 

i want click on submit button , each value 3 input fields sent on post connection, far tried accessing these values doing

$(this).parent("tr").children("td input").val(); 

which results in undefined result.

parent selects parentnode element of selected element(if matches specified selector), can use closest method:

$('tr input[type=submit]').click(function(event) {    event.preventdefault();    var data = $(this).closest('tr').find('input').serializearray();      // using "siblings" method         // var data = $(this).parent('td').siblings().find('input').serializearray(); }); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -