2012-08-09 52 views
0

後的懸停提示貼我使用這個jQuery Star Rating pluginjQuery的星級插件 - 如何使點擊

它的工作,但我「試圖讓懸停提示停留在頁面上我點擊後,目前。單擊並移動鼠標移開後,在前看不見。

<script> 
$(function(){ 
$('.hover-star').rating({ 
    focus: function(value, link){ 
    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> 

<form id="ratingform"> 
<table width="100%" cellspacing="10"> 
<tr><Td>Hover over the stars and then click</td></tr> 
<tr> 
<td valign="top" width=""> 
<div class="Clear"> 
<div> 
<input class="hover-star" type="radio" name="rating" value="1" title="Very poor"/> 
<input class="hover-star" type="radio" name="rating" value="2" title="Poor"/> 
<input class="hover-star" type="radio" name="rating" value="3" title="OK"/> 
<input class="hover-star" type="radio" name="rating" value="4" title="Good"/> 
<input class="hover-star" type="radio" name="rating" value="5" title="Very Good"/> 
<span id="hover-test" style="margin:0 0 0 20px;"></span> 
</td> 
</tr> 
</table> 

回答

0

您可以使用「回調」功能,並使用相同的代碼中的「焦點」功能,「回調」執行功能時,一個明星點擊:

$(function(){ 
$('.hover-star').rating({ 
    focus: function(value, link){ 
    .. 
    }, 
    blur: function(value, link){ 
    .. 
    }, 
    callback: function(value, link){ 
    var tip = $('#hover-test'); 
    tip[0].data = tip[0].data || tip.html(); 
    tip.html(link.title || 'value: '+value); 
    } 
});