1

div 内の項目をループする each ループがあります。

$(":radio[id^=lt]:checked,:hidden[id^=lt]", "#entry_"+item_id).each(function() {
    // Get values here
});

親の tr が非表示になっていないものだけを取得するようにループ コードを変更するにはどうすればよいですか (以下の CT を参照)。入力は、ラジオまたは隠しタイプの可能性があります。

<div class="entry" style="" id="entry_1117178">
    <table width="100%">
        <tbody>
            <tr>
                <td align="right"><label class="lbl_ln" for="lname_1117178" id="null_1117178">Name on License:&nbsp;</label></td>
                <td align="left"><input type="text" name="lname" class="lname" id="lname_1117178"></td>
            </tr>
            <tr>
                <td align="right"><label class="lbl_lic" for="ln_1117178" id="lbl_1117178">License:&nbsp;</label></td>
                <td align="left"><input type="text" class="ln" name="ln" id="ln_1117178"></td>
            </tr>
            <tr class="InfoCol" id="InfoCol_AL" style="display: none;">
                <td class="TypeCol" id="InfoType_220574">
                    <input type="hidden" class="lt_" id="lt_1117178_220574" name="lt_1117178_220574" value="220574">
                    <label id="lbl_lt_220574" class="lt_" for="lt_1117178"></label>
                </td>
            </tr>
            <tr class="InfoCol" id="InfoCol_CT" style="display: table-row;">
                <td class="TypeCol" id="InfoType_181258">
                    <input type="hidden" class="lt_" id="lt_1117178_181258" name="lt_1117178_181258" value="181258">
                    <label id="lbl_lt_181258" class="lt_" for="lt_1117178"></label>
                </td>
            </tr>
            <tr class="InfoCol" id="InfoCol_DC" style="display: none;">
                <td class="TypeCol" id="InfoType_183820">
                    <input type="radio" class="lt_" id="lt_1117178_183820" name="lt_1117178_183820" value="183820">
                    <label id="lbl_lt_183820" class="lt_" for="lt_1117178_183820">Item 1</label>
                </td>
                <td class="TypeCol" id="InfoType_183821">
                    <input type="radio" class="lt_" id="lt_1117178_183821" name="lt_1117178_183821" value="183821">
                    <label id="lbl_lt_183821" class="lt_" for="lt_1117178_183821">Item 2</label>
                </td>
            </tr>
        </tbody>
    </table>
</div>

上記のコードの場合、ID=lt_1117178_181258 の入力の値を取得したいだけです

4

2 に答える 2

3
$(":radio[id^=lt]:checked,:hidden[id^=lt]", "#ce_entry_"+item_id).each(function() {
    if ( $(this).closest('tr').is(':visible') ) {
        // Get values here
    }
});
于 2013-02-15T17:50:01.167 に答える
1

これは少しきれいに見えます:

$("input", ".InfoCol:visible").each(function() {
  //whatever
});

少し単純化しすぎているかもしれませんが、あなたが示したhtmlに基づいて、うまくいくと思います...

于 2013-02-15T17:53:57.270 に答える