Dan Wier Dan Wier - 7 months ago 22
jQuery Question

jquery .find('input').each

I have a row that contains inputs down a few descendants. What I am trying to do is capture the values of the children inputs when a button within the row is clicked. I can then use the values further down the line but am not sure how to extract the values properly. Any suggestions on what I have?

<div class="row">
<div class="form-horizontal">
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-10"><input type="text" value='0' class="form-control" >
<div class="col-sm-offset-2 col-sm-10">
<button type="button" class="btn btn-default updateButton">Update</button>

$('.updateButton').on('click', function () {
var inputs = [];
$(this).parent('.row').find('input').each(function (i) {


If I understand you correctly, you are very close. You probably want something like this:

$('.updateButton').on('click', function() {
    var inputs = [];
    $(this).closest('.row').find('input').each(function() {