Please I have the following markup :
<div class="closet">
<input name="hello1" class="input" />
</div>
<div class="closet">
<input name="hello2" class="input" />
</div>
and I want to attribute the input name and set another value (example hello5 and hello6) , so this is my code :
var i = 5;
$('.closet').each(function (k)
{
i++;
$('.input').attr('name', 'hello'+i);
});
But the problem it gave me for both inputs the value “hello6”.
Please have you any advise ?
Replace
with
so to change the
.inputthat is inside the.closeton which your iteration is.