【发布时间】:2015-05-07 03:58:30
【问题描述】:
jsfiddle 链接:http://jsfiddle.net/u9gpsb8h/20/ 我想根据 jquery 标签滑块过滤表。
类似于 query show tr where td1
我有两个滑块 1 和 2,现在我想根据滑块值过滤表格滑块 1 代表过滤器 a,滑块 2 代表过滤器 b。
问题是我的代码仅适用于当前标签时工作正常
下面是我的js代码
$(function() {
$( "#slider1" ).slider({
value: 20,
min:0,
max:20,
orientation: "horizontal",
range: "min",
animate: true,
slide: function( event, ui ) {
$('#s1').html(jQuery('#slider1').slider('value'));
// in this function we can define what happens when a user changes the sliders
var table = document.getElementById("theTable");
for (var i = 1, row; row = table.rows[i]; i++) {
//iterate through rows (we SKIP the first row: counter starts at 1!)
for (var j = 0, col; col = row.cells[j]; j++) {
//iterate through columns: if first column not in range: HIDE, else SHOW
if (j == 0) { // if first column
if ($(col).html() <= jQuery('#slider1').slider('value')) {
// if in interval
$(row).show();
} else {
$(row).hide();
}
}
}
}
}
});
$( "#slider2" ).slider({
value: 20,
min:0,
max:20,
orientation: "horizontal",
range: "min",
animate: true,
slide: function( event, ui ) {
$('#s2').html(jQuery('#slider2').slider('value'));
// in this function we can define what happens when a user changes the sliders
var table = document.getElementById("theTable");
for (var i = 1, row; row = table.rows[i]; i++) {
//iterate through rows (we SKIP the first row: counter starts at 1!)
for (var j = 0, col; col = row.cells[j]; j++) {
//iterate through columns: if first column not in range: HIDE, else SHOW
if (j == 1) { // if first column
if ($(col).html() <= jQuery('#slider2').slider('value')) {
// if in interval
$(row).show();
} else {
$(row).hide();
}
}
}
}
}
});
});
如何根据滑块值对表格进行排序我是新手请指导我这样做
【问题讨论】:
-
您是否尝试按增量对列进行排序?每个增量更正确的排序?不明白这个问题。
-
是的,幻灯片完成后立即排序
-
那么为什么要使用滑块,按钮不能正常工作,如果排序只发生一次,为什么还需要滑块呢?
-
不是每次增量一次,我要排序
标签: javascript jquery html css