为什么一颗星星都不亮,但是也不报错?
<script> var rating = (function(){ //点亮整颗 var LightEntire = function(el,options){ this.$el = $(el); this.$item = this.$el.find("rating-item"); this.opts = options; }; LightEntire.prototype.init = function(){ this.lightOn(this.opts.num); this.bindEvent(); }; LightEntire.prototype.lightOn = function(num){ num = parseInt(num); this.$item.each(function(index){ if(index < num){ $(this).css("background-position",'0 -67px'); }else{ $(this).css("background-position",'0 0'); } }); }; LightEntire.prototype.bindEvent = function(){ var self = this; self.$el.on("mouseover",".rating-item",function(){ self.lightOn($(this).index() + 1); }).on('click',".rating-item",function(){ self.opts.num = $(this).index()+1; }).on("mouseout",function(){ self.lightOn(self.opts.num); }) }; //默认参数 var defaults = { num:0, readOnly:false, select:function(){}, chosen:function(){} }; //初始化 var init = function(el,options){ options = $.extend({},defaults,options); new LightEntire(el,options).init(); }; return {init:init} })(); rating.init("#rating",{ num:2 }); </script>
对照了两遍,没有找到哪里写错了,求帮帮忙