0

フィドル

更新パネルの更新後に更新パネルにあるテーブルで、
スパン ID が取得されません。

$(".csstablelisttd").live('mousedown', function (e)
                {
                    clearFields();

                    //This line gets the index of the first clicked row.
                    lastRow = $(this).closest("tr")[0].rowIndex;

                    var rowIndex = $(this).closest("tr").index();
                    colIndex = $(e.target).closest('td').index();
    var id =$('.csstextheader').find('td').eq(colIndex).find('span').attr('id');

});
<table id="contentPlaceHolderMain_tableAppointment" cellspacing="1" width="100%" bgcolor="#cccccc">
        <tr Class="csstextheader">
            <td class="csstextheader" width="70px">
                                        </td>
            <td class="csstextheader" width="70px">
                                            <b>Time Slot&nbsp;</b>
                                        </td>
            <td ID="9"><span id=9>CR (CR1)</span></td>
            <td ID="10"><span id=10>ES (ES1)</span></td>
            <td ID="11"><span id=11>MR (MR1)</span></td>
            <td ID="13"><span id=13>US (US1)</span></td>
        </tr>
</table>
4

1 に答える 1

1

あなたのセレクターは十分に正確ではありません。使用する

$('tr.csstextheader').find('td').eq(colIndex).find('span').attr('id')

使用できたことに注意してください

<th...

それ以外の

<td class="csstextheader"...

そして、あなたのコードは

$('th').eq(colIndex).find('span').attr('id')
于 2012-10-30T11:16:25.047 に答える