$(document).ready(function() { function show_month() { var terms = $('[name="term"]'); if ($('[name="payform"]:checked').val() == '0'){ $(terms[0]).closest('li').hide(); if (terms.index(terms.filter(':checked')) == 0){ $(terms[1]).prop('checked', true); } } else { $($('[name="term"]')[0]).closest('li').show(); } } show_month(); $('[name="payform"]').change(function(){ show_month() }); });