I have the following snipped of my page:
<div class="radio-group">
<input type="radio" name="group1" checked="checked" id="option1" value="option1"/>
<label for="option1">option1</label>
<input type="radio" name="group1" id="option2" value="option2"/>
<label for="option2">option2</label>
<input type="radio" name="group1" id="option3" value="option3"/>
<label for="option3">option3</label>
<input type="radio" name="group1" id="option4" value="option4"/>
<label for="option4">option4</label>
</div>
and this javascript code to select the hidden input after a click in the radios:
$("input[type='radio']").live("change", function () {
var el = this.parentNode.nextElementSibling;
el.value = this.value;
});
I want to write the line
var el = this.parentNode.nextElementSibling;
in a jQuery way. Thanks.
var el = $(this).parent().next().find("input[type='radio']");
el.val(this.value);
very easy. :)
lol didn't pay enough attention to the markup. :P fixed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With