html radio check
{% if classes|count > 1 %} <div class="class_checkbox" id="class_checkbox"> <label class="class_checkbox_button"> <input type="radio" name="classes" value="" {{ 'checked' if not class_id}}> 全部 </label> {% for c in classes %} <label class="class_checkbox_button"> <input type="radio" name="classes" value="{{c['class_id']}}" {{ 'checked' if c['class_id'] == class_id}}> {{c['name']}} </label> {% endfor %} </div> {% endif %}
$('#class_checkbox input[type="radio"]').change(function() { var class_id = $("input[name='classes']:checked").val(); var path = window.location.pathname; if(class_id){ path += '?class_id='+class_id; } window.location.href = path; });