如何获取此功能恢复显示所有过滤器被删除时的一切?恢复显示当所有过滤器被删除时全部
我试图改变if (attrColor == 'All') {...}
到if (attrColor == 'All' || attrColor == '') {...}
我已经贴了拨弄着这里的功能的一个简单的例子:http://jsfiddle.net/chayacooper/WZpMh/88/
$(document).ready(function() {
var selected = [];
$('#attributes-Colors *').click(function() {
var attrColor = $(this).data('color');
var $this = $(this);
if ($this.parent().hasClass("active")) {
$this.parent().removeClass("active");
selected.splice(selected.indexOf(attrColor),1);
}
else {
$this.parent().addClass("active");
selected.push(attrColor);
}
if (attrColor == 'All') {
$('#content').find('*').show();
} else {
$("#content").find("*").hide();
$.each(selected, function(index,item) {
$('#content').find('[data-color *="' + item + '"]').show();
});
}
return false;
});
});
不能看到你摆弄工作。得到:页面不能显示在输出部分?? – Sangeeta 2013-03-27 06:45:17
@Sangeeta - 在我的电脑上工作正常,尽管我只在Firefox上试过。您是否使用其他浏览器? – 2013-03-27 06:55:10