美文网首页我爱编程
关于bootstrap中switch的那些坑

关于bootstrap中switch的那些坑

作者: SKY_d408 | 来源:发表于2018-02-28 15:18 被阅读0次

    1.今天做一个关于bootstrap中switch(开关)的功能,通过点击事件来改变switch(开关)disabled属性,官方给出的初始化参数方法是

    $('[name="status"]').bootstrapSwitch({

            onText: "激活",

            offText: "未激活",

            onColor: "success",

            offColor: "info",

            size: "small",

            onSwitchChange: function(event, state) {

                            if(state == true) {

                                $(this).val("1");

                            } else {

                                $(this).val("2");

                            }

                                alert(state);

            }

    });

    后期想通过按钮来改变switch的属性可以参考下面几种方法;

    例如:$('#mButton').click(function(){  

                            $('#mySwitch input').bootstrapSwitch('toggleState');  

               })


    2.在引用bootstrap-switch.css时,当我们把开关设置成禁用状态时,鼠标移上去并没有变禁止符号,我试过用js来hover改变鼠标形状,但是没有什么用,唯一的方法就是修改bootstrap-switch.css中凡是带disabled的属性,里面有cursor:default ! important的全部改成not-allowed,这可以当做是bootstrap-switch中小小的bug

    相关文章

      网友评论

        本文标题:关于bootstrap中switch的那些坑

        本文链接:https://www.haomeiwen.com/subject/ipzbxftx.html