javascript - Bootstrap-table showAllColumns 方法

标签 javascript jquery twitter-bootstrap bootstrap-table

我有一个按钮可以显示 Bootstrap 表的所有列。当我点击时它不起作用。

代码:

    <table data-toggle="table">
        <thead>
        <tr>
            <th data-field="state" data-checkbox="true"></th>
            <th data-field="id" >ID</th>
            <th data-field="name">Name</th>
        </tr>
        </thead>
    </table>
    <button id="show_all">Show All columns</button>
    <button id="hide_all">Hide All columns</button>

<script>    

    $('#show_all').on('click', function(){
        $('table').bootstrapTable('showAllColumns');
    })

    $('#hide_all').on('click', function(){
        $('table').bootstrapTable('hideAllColumn');
    })

</script>

参见示例:

https://jsfiddle.net/ruzD/5b2vsdgy/

最佳答案

这是一个可行的解决方案。

$('#show_all').on('click', function(){
    $('table th').show();
})

$('#hide_all').on('click', function(){
    $('table th').hide();
})

关于javascript - Bootstrap-table showAllColumns 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39974807/

相关文章:

javascript - 如何在 Angular 中显示/隐藏按钮

javascript - 在 Angular 函数不起作用后调用 jquery 选择器(渲染问题?)

javascript - bootstrap 组件的导航侧边栏 + 动画部分指示器

css - 如何删除右侧的边距

html - 改变 Bootstrap 网格系统

javascript向导/助手插件

javascript - Flot 自定义工具提示插件

javascript - textarea 值是否为空 - 检查 jquery 是否不工作,为什么

javascript - JQuery show() 仅在我的函数完成后才起作用

javascript - JQuery 日期选择器在刷新时不显示