-1

我正在使用来自http://www.fyneworks.com/jquery/star-rating/#tab-Testing的 jquery 星级插件。我想为我的应用程序使用十进制星级。所以我正在使用

Test4 半星和分裂星

html代码如下。

<input class="star {split:2}" type="radio" value="0.5" name="test-4-rating-3" />
<input class="star {split:2}" type="radio" value="1.0" name="test-4-rating-3" />
<input class="star {split:2}" type="radio" value="1.5" name="test-4-rating-3" />
<input class="star {split:2}" type="radio" value="2.0" name="test-4-rating-3" />
<input class="star {split:2}" type="radio" value="2.5" name="test-4-rating-3" />
<input class="star {split:2}" type="radio" value="3.0" name="test-4-rating-3" />
<input class="star {split:2}" type="radio" value="3.5" name="test-4-rating-3" />
<input class="star {split:2}" type="radio" value="4.0" name="test-4-rating-3" />
<input class="star {split:2}" type="radio" value="4.5" name="test-4-rating-3" />
<input class="star {split:2}" type="radio" value="5.0" name="test-4-rating-3" />

脚本如下。

$('.star').rating({
       split: 2, 
       callback: function(value, link){
           alert(value);          
       }
   });

请建议我如何使用 {split:2} 以及如何在点击星星时获得额定值。工作会更受重视。

4

2 回答 2

1

So I'm taking a shot in the dark here, because the website you linked isn't very clear, but here's what I got.

  1. According to that website you need to use the special metadata plugin to get the splits to work. Presumably include this file in your HTML before the stars plugin.
  2. As far as I can tell they're just updating the value attribute of the form element, so you can probably access the value like this $(".star").val(), however as you said you want to see the value when you click on the thing, you'll have to follow their instructions.
  3. Are you making sure to wrap your JS in $(function() { }); or putting your JS at the end of the page?
  4. This plugin seems very outdated. I know the website mentions a recent update, but the code quality and links imply it's several years old. I highly recommend using a more modern jquery plugin for your stars, such as any of the several that are on github. Check out Raty which seems to have decent documentation.
于 2012-12-01T06:12:45.577 回答
0

@Jamund 的链接不再有效。似乎它现在就在这里。

https://github.com/jquery-orphans/jquery-metadata

我用过它,它对我有用。

于 2013-10-31T00:35:56.820 回答