1

次のようなグリッド行スキームがあります。

<tr>
    <td>110</td>
    <td><input class="client-chb" name="checkedRecords" type="checkbox" value="110" title="checkedRecords"></td>
    <td>Some name</td>
    <td>Some other name</td>
    <td>1.1.2012</td>
</tr>

選択したすべてのチェックボックスを取得し、それらの値を取得して、ajax 経由でサーバーに送信する関数が 1 つあります。

しかし、その ajax 投稿を行う直前に、3 と 4 を取得して、<td>テキスト スタイルを次のように変更したいと考えています。

<td><b>Some name</b></td>

逆にこれが必要です。または、より明確にするために、これは「既読としてマーク」および「未読としてマーク」メッセージ受信ボックスです。

function MarkAsUnread() {
    var idata = new Array();
    $(".client-chb:checked").each(function() {
        var test = $(this);
        // maybe here, test -> find next td -> change text
        idata.push($(this).val());
    });
    //other logic
}
4

2 に答える 2

2

次のことを試すことができます。

function MarkAsUnread() {
    var idata = new Array();
    $(".client-chb:checked").each(function() {
        $(this).closest('tr').find('td').slice(2, 4).wrapInner('<b/>')
        idata.push($(this).val());
    });
}
于 2012-07-28T15:21:03.140 に答える
0

TD 内にラップされた入力要素を反復処理しているため、最初に入力要素 (チェックボックス) の親を設定し、次に実行します。

お気に入り、

function MarkAsUnread() {
    var idata = new Array();
    $(".client-chb:checked").each(function() {
        var test = $(this).parent();
        var next1 = test.next();
        var next2 = test.next().next();
        idata.push(next1.val());
        idata.push(next2.val());
    });
    //other logic
}

次および次の TD のコンテンツを取得または設定するには、next1.val() および next2.val() を使用します。

于 2012-07-28T15:19:25.547 に答える