我在搜索linking to quicksand prefiltered page时找到了这个答案,我对代码进行了一些编辑,使我的网址更加友好,数据在4列中过滤,我想为列的项目分配一个特定的类#1和#4列项目的另一个类,除了将类分配给过滤数据的部分外,所有代码都运行良好。 请帮助我,我将非常感谢您的努力。
$(document).ready(function() {
// get the action filter option item on page load
var $filterType = $('#sidebar .filter a.active').attr('data-value');
// get and assign the ourHolder element to the
// $holder varible for use later
var $holder = $('.filter-container');
// clone all items within the pre-assigned $holder element
var $data = $holder.clone();
var $button = $('#sidebar .filter a');
var $all = $('.filter-container .part').data('type') === 'all';
// reset the active class on all the buttons
$button.removeClass('active');
// assign the class of the clicked filter option
// element to our $filterType variable
var $filtered = 'greases';
$('a[data-value=' + $filtered + ']').addClass('active dark');
var $filteredData = $data.find('.part[data-type~=' + $filtered + ']').show();
// Assigning the classes
$filteredData.removeClass('alpha omega').each(function(index) {
if (index % 4 == 0) $(this).addClass('alpha');
if (index % 4 == 3) $(this).addClass('omega');
});
// call quicksand and assign transition parameters
$holder.quicksand($filteredData, {
duration: 750,
easing: 'easeInOutQuad'
});
});