zoukankan      html  css  js  c++  java
  • bootstrapSwitch 使用

    1、bootstrapSwitch 默认选项,加上checked表示true,不加表示false

    <input type="checkbox" id="" name="status" checked data-size="small" value="1">

    2、swich配置
    $('[name="status"]').bootstrapSwitch({
        onText: "上架",
        offText: "下架",
        onColor: "danger",
        offColor: "info",
        size: "small",
        onSwitchChange: function (event, state) {
            if (state == true) {
                $(this).val("1");
            } else {
                $(this).val("2");
            }
        }
    })

    3、触发swich事件。
    $('[name="status"]').on('switchChange.bootstrapSwitch', function (event, state) {
    if (state == true) {
    $.get("/gift/updatestatus", {
    id: $(this).attr("id"),
    status: '0'
    }, function (data) {
    console.log(data.result);
    location.reload()

    })
    } else {
    $.get("/gift/updatestatus", {
    id: $(this).attr("id"),
    status: '1'
    }, function (data) {
    console.log(data.result);
    location.reload()

    })

    }
    });
  • 相关阅读:
    计数排序【代码】
    快速排序【代码】
    基于最大堆实现最大优先队列
    Spring入门(1)
    AJAX初步理解
    选择器
    Hibernate的映射
    Hibernate配置(2)
    查看mysql的安装路径
    Hibernate入门(1)
  • 原文地址:https://www.cnblogs.com/paisen/p/9177843.html
Copyright © 2011-2022 走看看