Skip to content

Instantly share code, notes, and snippets.

@cwlsn
Created June 1, 2015 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwlsn/9404b61ef4396e9bc664 to your computer and use it in GitHub Desktop.
Save cwlsn/9404b61ef4396e9bc664 to your computer and use it in GitHub Desktop.
Have 3+ radio buttons that correspond to additional infomation/form elements. The value of each radio button corresponds to a div in the #grounds_more div. This hides all visible divs, then shows the desired one. Toggle doesn't cut it for 3+ items.
$("input[name='grounds']:radio").change( function () {
var val, obj;
val = $(this).val();
obj = $('#' + val);
$("#grounds_more > div:visible").fadeOut(300, function () {
obj.fadeIn(300);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment