1

I have the following code:

var table = $("#b-table");
table.find('tr').each(function (i) {
    var $tds = $(this).find('td'),    
    qLine       = $tds.eq(0).text(),
    qPartNumber = $tds.eq(1).text(),
    qComments   = $tds.eq(5).val();

    console.log(qLine);
    console.log(qPartNumber);
    console.log(qComments);

  });

qLine and qPartNumber are copying over fine, as these are text values within the td element, but qComments is not copying over, as within the td element is another input element, like so:

<td><input class="qComments" type="text"></td>

I've tried using:

$tds.eq(5).val();
$tds.eq(5).html();
$tds.eq(5).text();
$tds.input.eq(5).val();
$tds.eq(5).input.val();

and none of these capture the value of the input - and the last two error out for bad syntax.

1 Answer 1

3

Try something like this

$tds.eq(5).find("input").val();
Sign up to request clarification or add additional context in comments.

1 Comment

perfect - I should have thought of using find a second time. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.