繁体   English   中英

Bootstrap表页脚隐藏和显示

[英]Bootstrap table footer hide and show

我想根据某些条件显示和隐藏引导表的页脚。

如何使用javascriptJquery事件显示和隐藏页脚?

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

如何使用Javascript设置data-show-footer="true"的值?

将id或class赋予表是必须的。 读我 然后,您可以执行以下操作:

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

对于所有表元素,您需要使用class:

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

现在您可以访问JSfiddle的所有元素
由于您现在知道如何获取值,因此构造if语句应该很容易,因此if()then document.getElementsByClassName("table")[i].setAttribute('data-show-footer',false);

给表id,例如id="tbl" ,在jquery中你可以像

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

这是实现示例http://jsfiddle.net/L6tm1tt3/166/

暂无
暂无

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

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