Reputation: 3697
I have a radio button that is generated dynamically on the page. I change the id of this radio to locationInNearX (X being the next increment number).
I then have a text field which is associated with the radio button.
<label class="labelRadioBlack labelContainsInput" for="locationInNear0">
<input name="txtLocationAnywhereIn[0]" id="locationInNear0" value="inOrNear" type="radio" />In or near
</label>
<div class="inNearTextWrapper">
<input class="myWirrlMediumFormField" type="text" name="txtLocationAnywhereInLocation[0]" id="txtLocationAnywhereInLocation[0]" value="" />
</div>
I need to change the name of the next input field after the radio button. How can this be done using jQuery?
Upvotes: 0
Views: 90
Reputation: 72672
var wrapper = $('#locationInNear0').closest('label').next();
$('input', wrapper).attr('name', 'newvalue');
Upvotes: 1