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;
    });

 

posted @ 2016-12-26 14:42  一样菜  阅读(781)  评论(0编辑  收藏  举报