-4

それぞれにテキストボックスがあるテーブルを作成しました。td各テキストボックスの値を行ごとに配列に格納する必要があります。

JSフィドル

SO望ましい出力のような

  array[0]->ABC1,S/W developer1,abc1,22z,123 // 1st row values
  array[1]->PQR2,S/W developer2,abc2,22z,123 // 2nd row values
4

1 に答える 1

1

各行の配列内のテキストボックス値 (tr ワイズ)

ワーキングデモhttp://jsfiddle.net/cse_tushar/zQNUW/10/

$("#update").click(function () {
    x = [];
    $('table tr:gt(0)').each(function () {
        y = '';
        $(this).find('td input[type="text"]').each(function () {
            y += $(this).val() + ' ';
        });
        if (y != '') {
            x.push($.trim(y))
        }
    });
    alert(x);
    console.log(x);
});

ワーキングデモhttp://jsfiddle.net/cse_tushar/zQNUW/7/

$("#update").click(function () {
    x = [];
    $('table tr td input[type="text"]').each(function () {
        x.push($(this).val());
    });
    alert(x);
    console.log(x);
});
于 2013-07-25T07:58:59.747 に答える