Following is my code,
$(document).ready(function () {
$("#es").hide();
$("#n").hide();
$('input[type="radio"]').click(function () {
if (this.value === "Yes")
$("#es").show();
else if (this.value === "No")
$("#n").show();
});
});
There are 2 radio buttons for yes and no.After selecting yes if select no only no option should be selected but here both buttons are getting selecte.How can i rectify this?
Just provide both of them the same name. You don't need javascript to do that.
<label><input type="radio" name="group" id="es" value="Yes"/>Yes</label>
<label><input type="radio" name="group" id="n" value="No"/>No</label>
Fiddle
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