第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么我的鼠標(biāo)經(jīng)過事件,打印出多個

http://img1.sycdn.imooc.com//596b4b490001e6a111660368.jpg

<script type="text/javascript">

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);

if(!this.opts.readOnly){

this.bindEvent();

}

};

lightEntire.prototype.lightOn = function(num){

num = parseInt(num);

this.$item.each(function(index){

if(index < num){

$(this).css('background-position','0 -40px')

}else{

$(this).css('background-position','1px 0')

}

});

};

lightEntire.prototype.bindEvent = function(){

var self = this;

var itemLength = self.$item.length;

//事件綁定

self.$el.on('mousemove','.rating-item',function(){

var num = $(this).index() + 1;

self.lightOn(num);

//短路寫法,只有&&前面的成立,才能執(zhí)行后面的代碼

(typeof self.opts.selected === 'function') && self.opts.selected.call(this,num,itemLength);

//在父容器上觸發(fā)一個事件

self.$el.trigger('selected',[num,itemLength]);

}).on('click','.rating-item',function(){

self.opts.num = $(this).index() + 1 ;

//短路寫法,只有&&前面的成立,才能執(zhí)行后面的代碼

(typeof self.opts.chosen === 'function') && self.opts.selected.call(this,self.opts.num,itemLength);

//在父容器上觸發(fā)一個事件

self.$el.trigger('chosen',[self.opts.num,itemLength]);

}).on('mouseout',function(){

self.lightOn(self.opts.num);

})

};

//默認(rèn)參數(shù)

var defaults = {

num:0,

readOnly:false,//是否只讀

selected:function(){},

chosen:function(){}

}

//初始化

var init = function(el,options){

options = $.extend({},defaults,options);//用戶傳遞參數(shù)時,使用傳遞參數(shù),options的內(nèi)容覆蓋defalts。生成的內(nèi)容存在空對象里。

new lightEntire(el,options).init();

}

return {

init:init

}

})();

rating.init('#rating',{

num:2,

// selected:function(num,total){

// console.log(num+'/'+ total)

// },

})

$('#rating').on('selected',function(e,num,total){

console.log(num+'/'+ total)

}).on('chosen',function(e,num,total){

console.log(num+'/'+ total)

})

</script>


正在回答

2 回答

西小勺說得對

0 回復(fù) 有任何疑惑可以回復(fù)我~

mouseover打成了mousemove

1 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

為什么我的鼠標(biāo)經(jīng)過事件,打印出多個

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號