次のマークアップをお願いします。
<div class="closet">
<input name="hello1" class="input" />
</div>
<div class="closet">
<input name="hello2" class="input" />
</div>
入力名に属性を付けて別の値(例:hello5とhello6)を設定したいので、これが私のコードです:
var i = 5;
$('.closet').each(function (k)
{
i++;
$('.input').attr('name', 'hello'+i);
});
しかし、それが両方の入力に対して私に与えた問題は、値「hello6」です。
何かアドバイスはありますか?