<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>Jquery评分代码实例 by 25175</title>
<meta name="Design Corp" content="顺通网络" />
<meta name="Author" content="powered by 25175">
<meta name="description" content="Jquery评分代码实例,25175-你我一起舞-软件定制服务"/>
<meta name="Keywords" content="Jquery评分代码实例" />
<script src="images/jquery.js"></script>
<link href="images/startcss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script type="text/javascript">
$.fn.studyplay_star=function(options,callback){
//默认设置
var settings ={
MaxStar :20,
StarWidth :23,
CurrentStar :5,
Enabled :true,
Half :0
};
if(options) { jQuery.extend(settings, options); };
var container = jQuery(this);
container.css({"position":"relative"})
.html('<ul class="studyplay_starBg"></ul>')
.find('.studyplay_starBg').width(settings.MaxStar*settings.StarWidth)
.html('<li class="studyplay_starovering" style="width:'+settings.CurrentStar*settings.StarWidth+'px; z-index:0;" id="studyplay_current"></li>');
if(settings.Enabled)
{
var ListArray = "";
if(settings.Half==0)
{
for(k=1;k<settings.MaxStar+1;k++)
{
ListArray +='<li class="studyplay_starON" style="width:'+settings.StarWidth*k+'px;z-index:'+(settings.MaxStar-k+1)+';"></li>';
}
}
if(settings.Half==1)
{
for(k=1;k<settings.MaxStar*2+1;k++)
{
ListArray +='<li class="studyplay_starON" style="width:'+settings.StarWidth*k/2+'px;z-index:'+(settings.MaxStar-k+1)+';"></li>';
}
}
container.find('.studyplay_starBg').append(ListArray)
container.find('.studyplay_starON').hover(function(){
$(this).removeClass('studyplay_starON').addClass("studyplay_starovering");
$("#studyplay_current").hide();
},
function(){
$(this).removeClass('studyplay_starovering').addClass("studyplay_starON");
$("#studyplay_current").show();
})
.click(function(){
var studyplay_count = settings.MaxStar - $(this).css("z-index")+1;
if(settings.Half==0)
$("#studyplay_current").width(studyplay_count*settings.StarWidth)
if(settings.Half==1)
$("#studyplay_current").width(studyplay_count*settings.StarWidth/2)
//回调函数
if (typeof callback == 'function') {
if(settings.Half==0)
callback(studyplay_count);
if(settings.Half==1)
callback(studyplay_count/2);
return ;
}
})
}
}
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#z").studyplay_star({MaxStar:12,CurrentStar:2,Enabled:true,Half:1},function(value){alert(value)});
});
</script>
<p> </p>
<p> </p>
<p> </p>
<div id="z"></div>
<a href="http;//www.25175.com">25175</a>
</body>
</html>