Problem with slideUp()/slideDown() in a function
I have a form with some yes/no radio boxes if a box is checked I want it to display another field and I've built a function to do this. It will slideDown() on yes but it will not slideUp() on no. however it will hide() on no.
- function extraData(base){
var extra_item= $("#"+base+"_extra").hide();
var radio_no = $("#"+base+"_no");
var radio_yes = $("#"+base+"_yes");
radio_yes.change(function() {
extra_item.slideDown("medium");
});
radio_no.change(function() {
extra_item.slideUp("fast");
});
}
- $().ready(function() {
extraData("evicted");
});
snippit of form
- <label>Have you ever been evicted? <span class="required">*</span></label>
<div class="radioGroup">
<label>
<input name="evicted"id="evicted_no"value="no"class="radio"type="radio">
No</label>
<label>
<input name="evicted"id="evicted_yes"value="yes"class="radio"type="radio">
Yes</label>
</div>
<div id="evicted_extra">
<label for="evicted_explain">Explain</label>
<input name="evicted_explain" id="evicted_explain">
</div>