コンテナにいくつかの入力フィールドがあり、ユーザーはこれらのフィールドを乗算できます。コンテナに基づいて入力フィールドの名前を変更する必要があります。
<div class="stations">
<input type="radio" name="pp[prc][0][station][0][id]">
<input type="radio" name="pp[prc][0][station][1][id]">
</div>
これは私の HTML フォームです。
$(".stations").each(function(sIndex){
//Loop thru all .station
$("input:radio", $(this)).each(function(rIndex){
//Loop thru all radio buttons inside that container and change their names accordingly
$("input:radio", $(this)).attr('name','pp[prc]['+sIndex+'][stations]['+rIndex+'][id]');
});
});
これを行うと、何らかの理由でユーザーが複製され<div class="station">
、その内容がラジオボタンの名前に応じて変更されません。どこで間違っていますか?