0

我想在本地存储搜索结果的值,然后添加现有结果。

function filterProd(filter) {
    var f = ".f_" + filter;
    if ($.inArray(f, filters) > -1) filters = $.grep(filters, function (val) {
        return val != f;
    });
    else filters.push(f);

    if (filters.length == 0) {
        $(".f_all").show(); // show all products
        $("#filtered").hide(); // hide reset button
        return;
    } else {
        $("#filtered").show(); // show reset button
    }

    $(".f_all").hide(); // first hide all products
    $(filters.join("")).show(); // show products only for this category
}

想做联合代替拦截。

JSfiddle

4

1 回答 1

2

I believe all you need to do is change this

$(filters.join("")).show();

to

$(filters.join(",")).show();

This way instead of .class1.class2.class3... you get .class1,.class2...

于 2013-02-08T14:24:48.073 回答