【问题标题】:How to highlight the selected custom icon with raty如何用比率突出显示选定的自定义图标
【发布时间】:2018-01-01 22:33:41
【问题描述】:

你好

我正在使用带有 iconRange 选项的raty,我想知道如何才能仅突出显示选定的自定义图标。

我的代码是

$(".ratySmiley").raty({
    starType: 'i',
    hints: ['bad', 'poor', 'regular', 'good', 'gorgeous'],
    iconRange: [
        {range: 1, on: 'icon icon-nothappy', off: 'icon icon-nothappy'},
        {range: 2, on: 'icon icon-mehh', off: 'icon icon-mehh'},
        {range: 3, on: 'icon icon-nomood', off: 'icon icon-nomood'},
        {range: 4, on: 'icon icon-happy', off: 'icon icon-happy'},
        {range: 5, on: 'icon icon-veryhappy', off: 'icon icon-veryhappy'}
    ]
});

根据文档,我只找到了一个示例,其中 single 选项设置为 true,但只有在您的图标相同时才有效...

如果您对此有所了解,请帮助我。

托马斯

【问题讨论】:

    标签: javascript jquery rating-system raty


    【解决方案1】:

    我找到了解决办法

    我写了一个小 js 函数,它为点击的笑脸添加了一个id = 'active',这样我以后可以用 css 对其进行调整。

    function clickHandle(element, event) {
        $(element).children().each(function () {
            $(this).removeAttr("id");
        });
        $(event.target).attr("id", "active");
    }
    

    希望对你有帮助。

    托马斯

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-16
      • 1970-01-01
      • 1970-01-01
      • 2014-12-28
      • 2011-08-28
      • 2010-10-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多