简体   繁体   中英

jQuery Star Rating Plugin

I am playing with star rating plugin, but I can't configure it correctly, to show hover label on the right side, like on this page Test-3B:

http://www.fyneworks.com/jquery/star-rating/#tab-Testing

<script>
$(function(){
$('.star').rating({
focus: function(value, link){
// 'this' is the hidden form element holding the current value
// 'value' is the value selected
// 'element' points to the link element that received the click.
var tip = $('#hover-test');
tip[0].data = tip[0].data || tip.html();
tip.html(link.title || 'value: '+value);
},
blur: function(value, link){
var tip = $('#hover-test');
$('#hover-test').html(tip[0].data || '');
}
});
});

</script>
<input type="radio" name="rating" value="1" style="margin: 0;" class="star"  title="Very     poor"/>
    &nbsp;
<input type="radio" name="rating" value="2" style="margin: 0;" class="star" title="Poor"/>
    &nbsp;
<input type="radio" name="rating" value="3" style="margin: 0;" class="star" title="OK"/>
    &nbsp;
<input type="radio" name="rating" value="4" style="margin: 0;" class="star" title="Good"/>
    &nbsp;
<input type="radio" name="rating" value="5" style="margin: 0;" class="star" title="Very good"/>
<span id="hover-test" style="margin:0 0 0 20px;">Hover tips will appear in here</span><br />

I tried your plugin and it works great.

I put the source code here : http://jsfiddle.net/VgWtG/

You can test it by yourself. For your code, try to put <script type='text/javascript'> instead of </script> . Then, surround your set of inputs with a div .

But i'm pretty sure that your problem comes from a missing include (check it in the source code I gave you). Regards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM