Bootstrap表页脚隐藏和显示

时间:2017-03-24 13:11:53

标签: javascript jquery twitter-bootstrap

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

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

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

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

2 个答案:

答案 0 :(得分:0)

为表格提供id或class是必须的。 Read Me。然后你可以做这样的事情:

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

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

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()然后document.getElementsByClassName("table")[i].setAttribute('data-show-footer',false);

答案 1 :(得分:0)

为表格提供id,例如id="tbl",在jquery中,你可以这样做

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

这是实施http://jsfiddle.net/L6tm1tt3/166/

的示例
相关问题