使用 jquery 评级插件显示数据库中的评级平均值
所以我能够让它工作,没什么困难,但我有一个小问题。如果教程/文章的评分为 5,那么 5 颗星将为黄色,如果评分为 4 或 3,则相同。但是当评分为 0 时,它仍然会使第一个星变成黄色,而不是全部变成灰色。
我正在使用 http://zensoftware.org/archives/483 上找到的插件
,这里是指向包含代码的文本文件的链接 -> http://cmstutorials.org/code.txt
我不认为这是因为该插件,因为当我删除属性 selected="selected" 时,所有星星都会变成灰色。所以我猜这与我的代码有关
So I was able to make it work, nothing difficult however I have a small problem. if the tutorial/article has a rating of 5 then 5 stars will be yellow, same if it is a rating of 4 or 3. But when the rating is 0 it will still make the first star yellow instead of making them all grey.
I'm using the plugin found on http://zensoftware.org/archives/483
and here is a link to a text file containing the code -> http://cmstutorials.org/code.txt
I don't think it's because of the plugin because when I remove the attribute selected="selected" all the stars become grey. so I guess it's something with my code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它可能是 ceil 函数。如果评级大于零但小于一,天花板将返回一,即大于输入的最小整数。对于评级系统,我希望您确实想使用 floor - - 不大于输入的最大整数。这样一来,要获得 5 分,您就必须获得全部 5 分。
话虽如此,如果这种情况仍然发生而没有任何收视率,那么我上面所说的就没有意义了。
It might be the ceil function. If the rating is greater than zero but less than one, ceiling will return one, the smallest integer greater than the input. For a rating system I would expect that you would really want to use floor -- the largest integer not greater than the input. That way to get a rating of 5, you'd have to get all 5's.
Having said that, if this is still happening with no ratings whatsoever then what I've said above is moot.