0

次のコードがあります

<tr class="DataGridAlterItem" align="center">
<td align="center">
    <input id="ctl00_PageBody_grdCustomers_ctl117_rdoCustomerSelect" type="radio" name="rdo_ctl117" value="rdoCustomerSelect" onclick="check(this);" class="radio">
</td>

<div class="myDIV">
This is the related text for div###
</div>

私が達成しようとしているのは、TD「名前」(name="rdo_ctl117") の値を同じ行の DIV にコピーすることです。

最終結果は次のようになります

<tr class="DataGridAlterItem" align="center">
<td align="center">
    <input id="ctl00_PageBody_grdCustomers_ctl117_rdoCustomerSelect" type="radio" name="rdo_ctl117" value="rdoCustomerSelect" onclick="check(this);" class="radio">
</td>

<div class=""myDIV name="rdo_ctl117">
This is the related text for div###
</div>

クローンを使用してみましたが、入力要素全体をコピーしようとしました...名前属性のみが必要です。

next、prev、siblings なども試しましたが、期待どおりに動作しません。

$('input[name^="rdo_ctl"]').click(function(){
 var tblTitle = $(this).attr('name');
$(this).next().prop('title', tblTitle);
});

$('input[name^="rdo_ctl"]').click(function(){
    $(this).attr('name',name).appendTo('.myDIV', name);
});

助言がありますか?

4

1 に答える 1

0

Fiddle DEMO

HTML

<table>
    <tr class="DataGridAlterItem" align="center">
        <td align="center">
            <input id="ctl00_PageBody_grdCustomers_ctl117_rdoCustomerSelect" type="radio" name="rdo_ctl117" value="rdoCustomerSelect" class="radio" />
        </td>
        <td>
            <div class="myDIV">This is the related text for div###</div>
        </td>
    </tr>
</table>

js

$('input[name^="rdo_ctl"]').click(function () {
    var tblTitle = $(this).attr('name');
    $(this).closest('td').next().find('div.myDIV').prop('name', tblTitle);
});
于 2013-10-30T14:54:12.683 に答える