$.fn.studyplay_star=function(options,callback){
//默认设置
var settings ={
MaxStar :20,
StarWidth :23,
CurrentStar :5,
Enabled :true
};
if(options) { jQuery.extend(settings, options); };
var container = jQuery(this);
container.css({"position":"relative"})
.html('
')
.find('.studyplay_starBg').width(settings.MaxStar*settings.StarWidth)
.html('
');
if(settings.Enabled)
{
var ListArray = "";
for(k=1;k{
ListArray +='';
}
container.find('.studyplay_starBg').append(ListArray)
.find('.studyplay_starON').hover(function(){
$("#studyplay_current").hide();
$(this).removeClass('studyplay_starON').addClass("studyplay_starovering");
},
function(){
$(this).removeClass('studyplay_starovering').addClass("studyplay_starON");
$("#studyplay_current").show();
})
.click(function(){
var studyplay_count = settings.MaxStar - $(this).css("z-index")+1;
$("#studyplay_current").width(studyplay_count*settings.StarWidth)
//回调函数
if (typeof callback == 'function') {
callback(studyplay_count);
return ;
}
})
}
}
例如:$("#z").studyplay_star({MaxStar:12,CurrentStar:2,Enabled:true,Half:1},function(value){alert(value)});