jQuery 星级评分滑块过滤器

jQuery star rating slider filter

我正在尝试在 jquery 中制作星级评分滑块过滤器,但没有任何反应。

过滤器是:

<div class="panel-collapse collapse filters-container" id="rating-filter">
    <div class="panel-content">
        <div class="five-stars-container editable-rating" data-label-fullrating="5 STELE" data-label-norating="Fara" data-label-rating="STELE" data-rating="1" id="rating"></div><span>TOATE</span>
    </div>
</div>

要过滤的 Div 是:

<div data-stars="2">2 STARS</div>
<div data-stars="2">2 STARS</div>
<div data-stars="4">5 STARS</div>
<div data-stars="3">3 STARS</div>
<div data-stars="1">1 STARS</div>

我的非工作 jQuery 代码是:

tjq("#rating").slider({
    range: "min",
    value: 4,
    min: 0,
    step: 1,
    max: 5,
    slide: function(event, ui) {
        var label_rating = '';
        if (ui.value == 0) {
            label_rating = tjq("#rating").data('label-norating');
        } else if (ui.value == 5) {
            label_rating = tjq("#rating").data('label-fullrating');
        } else {
            label_rating = ui.value + ' ' + tjq("#rating").data('label-rating');
        }
        tjq("#rating-filter .panel-content > span").text(label_rating);
        $('div[data-stars]').each(function() {
            var dStars = $(this).attr('data-stars');
            if (dStars < ui.values[0] || dStars > ui.values[1]) $(this).hide();
            else $(this).show();
        });
    }
});

如果你能帮我解决这个问题,先谢谢你了。

尝试改变

if (dStars < ui.values[0] || dStars > ui.values[1])

来自

if (dStars != ui.value) 

DEMO

$("#rating").slider({
    range: "min",
    value: 4,
    min: 0,
    step: 1,
    max: 5,

    slide: function(event, ui) {
        var label_rating = '';
        if (ui.value == 0) {
            label_rating = $("#rating").data('label-norating');
        } else if (ui.value == 5) {
            label_rating = $("#rating").data('label-fullrating');
        } else {
            label_rating = ui.value + ' ' + $("#rating").data('label-rating');
        }
        $("#rating-filter .panel-content > span").text(label_rating);
        $('div[data-stars]').each(function() {
            var dStars = $(this).attr('data-stars');

            if (dStars != ui.value) 
               $(this).hide();
            else 
               $(this).show();
        });
    }
});