Radiobuttons and jQuery
Posted
by SnowJim
on Stack Overflow
See other posts from Stack Overflow
or by SnowJim
Published on 2010-06-13T10:55:10Z
Indexed on
2010/06/13
11:02 UTC
Read the original article
Hit count: 243
Hi,
I have the following radiobuttons rendered in MVC :
<div class="radio" id="ModelViewAd.TypeOfAd">
<input checked="checked" id="ModelViewAd.TypeOfAd_Ad" name="ModelViewAd.TypeOfAd.SelectedValue" type="radio" value="Ad" />
<label for="ModelViewAd.TypeOfAd_Ad">Annons</label><br>
<input id="ModelViewAd.TypeOfAd_Auktion" name="ModelViewAd.TypeOfAd.SelectedValue" type="radio" value="Auktion" />
<label for="ModelViewAd.TypeOfAd_Auktion">Auktion</label><br>
</div>
Now I need to hide the id=divEndDate element based on the value on the radiogroup.
I have tried this :
$(document).ready(function () {
$("#TypeOfAd_Auktion").click(function () {
if ($(this).checked) {
$("divEndDate").css("visibility", "visible");
}
else {
$("divEndDate").css("visibility", "hidden");
}
});
$("#ModelViewAd.TypeOfAd_Ad").click(function () {
if ($(this).checked) {
$("divEndDate").css("visibility", "hidden");
}
else {
$("divEndDate").css("visibility", "visible");
}
});
});
Now one of these are triggered when switching between the radio buttons? How to solve this?
© Stack Overflow or respective owner