twitter-bootstrap buttons javascript doesnt work

2020-04-14 03:26发布

I have a control-group with a button group as checkboxes like this :

<div class="control-group" id="cyb3r" >
            <label class="control-label" for="c">C</label>
            <div class="btn-group navs controls" data-toggle="buttons-checkbox">
                <button class="btn" type="button">1</button>
                <button class="btn" type="button">2</button>
                <button class="btn" type="button">3</button>
            </div>

</div>

and I include these :

<link rel="stylesheet"
    href="<?php echo base_url('assets/style/style.css');?>">
<link rel="stylesheet"
    href="<?php echo base_url('assets/style/bootstrap.min.css');?>">
<script
    type="text/javascript"
    src="<?php echo base_url('assets/script/jquery.js')?>"></script>
<script
    type="text/javascript"
    src="<?php echo base_url('assets/script/bootstrap.min.js')?>"></script>
<script
    type="text/javascript"
    src="<?php echo base_url('assets/script/bootstrap-button.js')?>">
    </script>
<script
    type="text/javascript"
    src="<?php echo base_url('assets/script/js.js')?>"></script>

and js.js :

$(function(){
    $('#cyb3r').button();  
});

I tried these also :

$(function(){
    $('.navs').button();  
});

$(function(){
    $('.control-group').button();  
});

but none of them work for that checkbox group. but why?

2条回答
smile是对你的礼貌
2楼-- · 2020-04-14 04:13

bootstrap.min.js already includes bootstrap-button.js

you can remove

<script
type="text/javascript"
src="<?php echo base_url('assets/script/bootstrap-button.js')?>">
</script>
查看更多
戒情不戒烟
3楼-- · 2020-04-14 04:19

Are you sure that all libraries are included correctly? Because for me it works fine: http://jsfiddle.net/QchpT/

查看更多
登录 后发表回答