我必须以5x5的网格显示一个表格。但是我的json数据可以有超过5列的数据。
使用jquery slider,如何根据slider的滚动改变table > td的数据。
下面是一个JSON对象:
var tData = [
["R1C1","R1C2","R1C3","R1C4","R1C5","R1C6","R1C7","R1C8","R1C9"],
["R2C1","R2C2","R2C3","R2C4","R2C5","R2C6","R2C7","R2C8","R2C9"],
["R3C1","R3C2","R3C3","R3C4","R3C5","R3C6","R3C7","R3C8","R3C9"],
["R4C1","R4C2","R4C3","R4C4","R4C5","R4C6","R4C7","R4C8","R4C9"],
["R5C1","R5C2","R5C3","R5C4","R5C5","R5C6","R5C7","R5C8","R5C9"]
];
字符串
默认情况下,数据如下表所示。
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __
| R1C1 | R1C2 | R1C3 | R1C4 | R1C5 |
|_ _ _ | _ _ _ _ _ _ | _ _ _|_ _ _ |
| R2C1 | R2C2 | R2C3 | R2C4 | R2C5 |
|_ _ _ | _ _ _ _ _ _ | _ _ _|_ _ _ |
| R3C1 | R3C2 | R3C3 | R3C4 | R3C5 |
|_ _ _ | _ _ _ _ _ _ | _ _ _|_ _ _ |
| R4C1 | R4C2 | R4C3 | R4C4 | R4C5 |
|_ _ _ | _ _ _ _ _ _ | _ _ _|_ _ _ |
| R5C1 | R5C2 | R5C3 | R5C4 | R5C5 |
|_ _ _ | _ _ _ _ _ _ | _ _ _|_ _ __|
型
在滑块滚动上,数据必须像下面这样更改。
_ _ _ _ _ _ _ _ _ _ _ _ _ __ _ _ _
| R1C2 | R1C3 | R1C4 | R1C5 | R1C6 |
| _ _ _|_ _ _ | _ _ _|_ _ _ |_ _ _ |
| R2C2 | R2C3 | R2C4 | R2C5 | R2C6 |
| _ _ _|_ _ _ | _ _ _|_ _ _ |_ _ _ |
| R3C2 | R3C3 | R3C4 | R3C5 | R3C6 |
| _ _ _|_ _ _ | _ _ _|_ _ _ |_ _ _ |
| R4C2 | R4C3 | R4C4 | R4C5 | R4C6 |
| _ _ _|_ _ _ | _ _ _|_ _ _ |_ _ _ |
| R5C2 | R5C3 | R5C4 | R5C5 | R5C6 |
| _ _ _|_ _ _ | _ _ _|_ _ __|_ _ _ |
型
在下一个卷轴上,它会变成
_ _ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _
| R1C3 | R1C4 | R1C5 | R1C6 | R1C7 |
|_ _ _ | _ _ _|_ _ _ |_ _ _ | _ _ _|
| R2C3 | R2C4 | R2C5 | R2C6 | R2C7 |
|_ _ _ | _ _ _|_ _ _ |_ _ _ | _ _ _|
| R3C3 | R3C4 | R3C5 | R3C6 | R3C7 |
|_ _ _ | _ _ _|_ _ _ |_ _ _ | _ _ _|
| R4C3 | R4C4 | R4C5 | R4C6 | R4C7 |
|_ _ _ | _ _ _|_ _ _ |_ _ _ | _ _ _|
| R5C3 | R5C4 | R5C5 | R5C6 | R5C7 |
|_ _ _ | _ _ _|_ _ __|_ _ _ | _ _ _|
型
你能建议如何使用jquery和slider来实现这一点吗?
1条答案
按热度按时间mzaanser1#
你可以用多种方法来实现这一点:在一个使用溢出的div中移动表,在表中添加和删除数据,或者我选择的方法,显示和隐藏特定的列。
HTML格式
字符串
CSS
型
JavaScript
型
工作示例:https://jsfiddle.net/Twisty/3osy7fvh/