html - 按下按钮可切换表

标签 html css button

如何制作一个带有按钮的可切换表格,以导致另一个表格的不同 View ?像这样:

如您所见,单击按钮后,您会转到另一个表格列表。

这是一个基地:http://jsbin.com/agavid/136/edit

需要类似的东西。

最佳答案

您可以创建多个不同的表格,并使用简单的 JS/jQuery 脚本根据按下的按钮显示和隐藏表格。

基本上,您会在开始时显示所有表格(以逐步增强),然后隐藏除第一个表格之外的所有表格。然后,当单击一个按钮时,隐藏所有表格并仅显示与该按钮关联的表格。

这是我正在谈论的演示。 http://jsfiddle.net/7Ywbn/2/

(function () {
var tables = $("table");
//Grabs all the tables
tables.hide().first().show();
//Hides all the tables except first
$("a.button").on("click", function () {
    //Adds eventListner to buttons
    tables.hide();
    //Hides all the tables
    var tableTarget = $(this).data("table");
    //Gets data# of button
    $("table#" + tableTarget).show();
    //Shows the table with an id equal to data attr of the button
})
})();

希望我正确理解了你的问题。

关于html - 按下按钮可切换表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21785312/

相关文章:

javascript - AngularJS 指令 transclude scope=false?

button - 在 PyGame 中创建按钮

Javascript:切换按钮无法正常工作

html - 单击和加载时按钮丢失 css 样式

javascript - Onmouseover 可以在超链接之外使用吗?

html - Bootstrap 响应式和选择框

asp.net - 如何用html和css实现这个header?

html - 为什么填充和边距不起作用?

css - 通过选中的选择器隐藏前一个元素

在 Wordpress 站点中使用关键帧进行 CSS 动画/转换