zoukankan      html  css  js  c++  java
  • fastadmin如何绑定开关按钮切换事件

    我不知道你怎么写的开关,我fastadmin从别处复制了一个开关,写了一段JS监听开关

    这是开关代码

    <input  id="a-switch" type="hidden" value="0">
    <a href="javascript:;" data-toggle="switcher" class="btn-switcher a-switch" data-input-id="a-switch" data-yes="1" data-no="0" >
                    <i class="fa fa-toggle-on text-success {eq name="$row.switch" value="0"}fa-flip-horizontal text-gray{/eq} fa-2x"></i>
    </a>

    这是监听的JS,我为了方便引用了JQ,你可以写原生js

    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
    <script>
        $('.a-switch').click(function () {
            var val = $('#a-switch').val();
            if(val == 0){
                // 此处写给你想控制的元素加上 disabled
                console.log(val);
            }else{
                // 此处写给你想控制的元素去掉 disabled
                console.log(val);
            }
        })
    </script>
  • 相关阅读:
    java实验二
    实验1
    响应式站点设计之使用指南
    掌管一个网站?给你九条忠告
    在本地App上设计Web代码
    订阅
    下载站焦点图
    个性化电影频道js
    展开收起播放列表
    onoff组件
  • 原文地址:https://www.cnblogs.com/apolloren/p/13369216.html
Copyright © 2011-2022 走看看