Twitter Bootstrap Button Group Control Radio Buttons/Checkboxes

后端 未结 5 776
攒了一身酷
攒了一身酷 2021-01-30 16:15

I am trying to use the Twitter Bootstrap button group as an actual set of form input controls. By default, these button groups can be made to function like a radio button or che

5条回答
  •  执笔经年
    2021-01-30 16:37

    With Bootstrap 3.2 put the hidden input in the middle of your button group container. Instead of the text content we take the value of th data-value field.

    Now insert a little javascript snippet into the onload part of your template.

    $('.checkit .btn').click(function() {
        $(this).parent().find('input').val($(this).data("value"));
    });
    

    So you only need to add .checkit to your button group and insert a hidden input field.

    With bootstrap 3.2 you can use button groups directly with radio- or checkbox-inputs

    See here: http://jsfiddle.net/DHoeschen/gmxr45hh/1/

提交回复
热议问题