0

我正在实现jquery 星级插件

单颗星估算工作正常,没问题。但我似乎无法得到半颗星的工作......

html源码:

<div class="stars">
   <span class="star-rating-control"><div class="rating-cancel" style="display: none;"><a title="Cancel Rating"></a></div><div role="text" aria-label="" class="star-rating rater-0 required {half:true} star-rating-applied star-rating-live" id="Answer1_Rating"><a title="1">1</a></div><div role="text" aria-label="" class="star-rating rater-0 required {half:true} star-rating-applied star-rating-live" id="Answer1_Rating"><a title="2">2</a></div><div role="text" aria-label="" class="star-rating rater-0 required {half:true} star-rating-applied star-rating-live" id="Answer1_Rating"><a title="3">3</a></div><div role="text" aria-label="" class="star-rating rater-0 required {half:true} star-rating-applied star-rating-live" id="Answer1_Rating"><a title="4">4</a></div><div role="text" aria-label="" class="star-rating rater-0 required {half:true} star-rating-applied star-rating-live" id="Answer1_Rating"><a title="5">5</a></div></span>
   <input class="required  {half:true} star-rating-applied" data-val="true" data-val-required="The Rating field is required." id="Answer1_Rating" name="Answer1.Rating" type="radio" value="1" style="display: none;">
   <input class="required  {half:true} star-rating-applied" id="Answer1_Rating" name="Answer1.Rating" type="radio" value="2" style="display: none;">
   <input class="required  {half:true} star-rating-applied" id="Answer1_Rating" name="Answer1.Rating" type="radio" value="3" style="display: none;">
   <input class="required  {half:true} star-rating-applied" id="Answer1_Rating" name="Answer1.Rating" type="radio" value="4" style="display: none;">
   <input class="required  {half:true} star-rating-applied" id="Answer1_Rating" name="Answer1.Rating" type="radio" value="5" style="display: none;">
</div>

查询:

 $('.stars :radio').rating();
4

2 回答 2

3

来自http://www.fyneworks.com/jquery/star-rating/

使用元数据插件通过类属性将高级设置传递给插件。

http://archive.plugins.jquery.com/project/metadata

于 2013-03-13T10:22:42.757 回答
0

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

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

我用过它,它对我有用。

于 2013-10-31T00:32:18.527 回答