Reputation: 227
I would like to get all the td values that are inside the tr tag. One of the td is button. So I should get current td values when I am clicking the button. I have tried something like this. But it is not working.
<tr class="danger">
<td><input type="text" value="5" id="cash" /></td>
<td><input type="text" value="20" id="turnover"/></td>
<td><input type="button" value="Update" id="update"/></td>
</tr>
$("#update").click(function(){
// Please suggest some logic here
});
Can anyone helped me in the Jquery part I would like to get the cash and turnover values when I am clicking update button.
Upvotes: 0
Views: 547
Reputation: 633
I've made a jsFIDDLE for example i put it in an alert and in the console log window. I don't know if you want to do some math with the values in that case you have to use parseInt() function parseInt explanation
$("#update").click(function(){
$('input[type="text"]').each(function(){
alert($(this).val());
/* or for example */
//console.log($(this).val());
});
});
Upvotes: 0
Reputation: 1630
u can do something like this:
$("#update").click(function(){
alert(('#cash').val()+' '+$('#turnover').val());
});
Upvotes: 1