简体   繁体   English

Bootstrap表页脚隐藏和显示

[英]Bootstrap table footer hide and show

I would like to show and hide the footer of a bootstrap table based on some conditions. 我想根据某些条件显示和隐藏引导表的页脚。

How can I show and hide footer using a javascript or Jquery event? 如何使用javascriptJquery事件显示和隐藏页脚?

<table data-toggle="table" data-url="/gh/get/response.json/wenzhixin/bootstrap-table/tree/master/docs/data/data1/" data-show-footer="true">

How can I set the value of data-show-footer="true" using Javascript ? 如何使用Javascript设置data-show-footer="true"的值?

Giving id or class to a table is a must. 将id或class赋予表是必须的。 Read Me . 读我 Then you can do something like this: 然后,您可以执行以下操作:

console.log(document.getElementById("table").getAttribute('data-show-footer')); //true

For all table elements you need to use class: 对于所有表元素,您需要使用class:

var len = document.getElementsByClassName("table");
for (let i=0; i< len.length;i++){
console.log(document.getElementsByClassName("table")[i].getAttribute('data-show-footer'));
}

Now you are able to access all elements JSfiddle 现在您可以访问JSfiddle的所有元素
Since you now know how to get the value it should be easy for you to construct if statement, so if() then document.getElementsByClassName("table")[i].setAttribute('data-show-footer',false); 由于您现在知道如何获取值,因此构造if语句应该很容易,因此if()then document.getElementsByClassName("table")[i].setAttribute('data-show-footer',false);

give id to the table eg id="tbl" and in jquery you can do like 给表id,例如id="tbl" ,在jquery中你可以像

if(condition)
{
   $("#tbl").attr("data-show-footer", "true");
}
else
{
   $("#tbl").attr("data-show-footer", "false");
}

here is the example of implementation http://jsfiddle.net/L6tm1tt3/166/ 这是实现示例http://jsfiddle.net/L6tm1tt3/166/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM