Hide/Show input when radio button is chosen, not working
Hello!
I have a few radio buttons and one text input. I'd like the text input visible only when one of the radio buttons is checked, then to hide or toggle when any others are checked. I was able to accomplish this with javascript but want to use jQuery.
HTML:
-
<label for="StandardShip"> <input id="StandardShip" type="radio" class="validation" value="86" checked="checked" />
<span class="name">Standard Shipping</span>
<p class="rl-m"><small>Earliest Date of Delivery:</small><small><span id="delivery-date"></span></small></p>
</label>
<div id="datepickerDiv"> <label for="datepicker" class="name rl-m">Desired Delivery Date:</label><br /> <input type="text" class="Field validation productAttributeFluidWidth rl-m" id="datepicker" value="" placeholder="ex. 01/01/2013" readonly />
<div class="cf"></div>
<hr />
</div>
<div id="2Day">
<label for="2DayShip"> <input id="2DayShip" type="radio" class="validation" value="89" />
<span class="name">Delivery by <span id="datepicker2"></span></span>
<p class="rl-m"><small>2 Day Express Shipping. Additional $27.00.</small></p>
</label>
</div>
<div id="3Day">
<label for="3DayShip"> <input id="3DayShip" type="radio" class="validation" value="90" />
<span class="name">Delivery by <span id="datepicker3"></span></span>
<p class="rl-m"><small>3 Day Express Shipping. Additional $17.00.</small></p>
</label>
</div>
Tried this but isn't working:
- $(function () {"#StandardShip").change(function () {
if ($(this).is(":checked")) $("#datepickerDiv").hide();
else $("#datepickerDiv").show();
});
});
Thank you very much!