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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

能不能把代碼貼出來,以方便學(xué)習(xí)?

視頻顯示內(nèi)容有限,能不能把代碼貼出來以方便學(xué)習(xí)

正在回答

1 回答

我自己跟著打的



<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>星級(jí)評(píng)分-第五種實(shí)現(xiàn)方式</title>

<style type="text/css">

body,ul,li{

padding: 0;

margin: 0;

}

li{

list-style-type: none;

}

.rating{

position: relative;

width:160px;

background: url(img/two.png) repeat-x;

margin: 100px auto;

}

.rating-display{

width: 0;

height: 32px;

background: url(img/two.png) repeat-x 0 -32px;

}

.rating-mask{

position: absolute;

left: 0;

top: 0;

width: 100%;/*跟隨父容器*/

}

.rating-item{

float: left;

width: 32px;

height: 32px;

cursor: pointer;

}

</style>

</head>

<body>

?<div class="rating" id="rating">

? <!-- <div class="rating-display"></div>

? <ul class="rating-mask">

? <li class="rating-item "></li>

? <li class="rating-item"></li>

? <li class="rating-item"></li>

? <li class="rating-item"></li>

? <li class="rating-item"></li>

? </ul> ?-->

?</div>


</body>

<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>

<script type="text/javascript">

var rating = (function(){

//策略

var strategies ={

entire:function(){

return 1;

},

half:function(){

return 2;

},

quarter:function(){

return 4;

}

};

//評(píng)分

var Rating = function(el,options){

this.$el = $(el);

this.opts = $.extend({},Rating.DEFAULTS,options); //用戶如果查了自定義參數(shù)options,就會(huì)覆蓋默認(rèn)參數(shù),然后傳給空對(duì)象,返回給opts保存

if(!strategies[this.opts.mode]){//如果設(shè)定的mode在strategies上不存在

this.opts.mode = 'entire';

}

this.ratio = strategies[this.opts.mode]();

this.opts.total *=this.ratio;

this.opts.num *=this.ratio;

this.itemWidth = 32/this.ratio;

this.displaWidth = this.opts.num * this.itemWidth;

};

Rating.DEFAULTS = {

mode:'entire',

total:5,

num:2,

readOnly:false,

select:function(){},

chosen:function(){},

};

Rating.prototype.init = function(){

this.buildHTML();//動(dòng)態(tài)創(chuàng)建HTML標(biāo)簽

this.setCSS();

if(!this.opts.readOnly){

this.bindEvent();

}

};

Rating.prototype.buildHTML = function(){//創(chuàng)建HTML

var html = '';

html+='<div class="rating-display"></div><ul class="rating-mask">';

for(var i=0; i<this.opts.total; i++)

{

html+='<li class="rating-item "></li>';

}

html+='</ul>';

this.$el.html(html);

};

Rating.prototype.setCSS = function(){//設(shè)置css

this.$el.width(this.opts.total * this.itemWidth);//父容器$el的總寬度通過width來設(shè)定

this.$display = this.$el.find('.rating-display') //獲取展示層

this.$display.width(this.displaWidth); //設(shè)置展示層的寬度

this.$el.find('.rating-item').width(this.itemWidth);

};

Rating.prototype.bindEvent = function(){

var self =this;//保存展示層,在下面一行后,this指的是當(dāng)前點(diǎn)擊的星星,只有在上面才表示rating實(shí)例化后的對(duì)象

//委托人是.rating-item也就是每一顆星星,事件是mouseover

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

var count = $(this).index()+1;//記錄當(dāng)前鼠標(biāo)滑動(dòng)到哪一顆星星上,this就是星星

self.$display.width(count * self.itemWidth);//count表示當(dāng)前是第幾顆星星

//判斷后再執(zhí)行self.opts.select,call改變this的指向,指向指向的星星,第二個(gè)參數(shù)是當(dāng)前是第幾顆星星,然后是總攻有多少星星

(typeof self.opts.select === "function")&&self.opts.select.call(this,count,self.opts.total);

//通過trigger觸發(fā)select函數(shù),然后傳遞參數(shù),傳遞參數(shù)必須在數(shù)組中

self.$el.trigger('select',[count,self.opts.total]);

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

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

self.displaWidth = count*self.itemWidth;

(typeof self.opts.chosen === "function")&&self.opts.chosen.call(this,count,self.opts.total);

self.$el.trigger('chosen',[count,self.opts.total]);

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

self.$display.width(self.displaWidth);

});

};

Rating.prototype.unbindEvent = function(){//解綁定

//$this.unbind('event name(s)', function name)

this.$el.off();//這個(gè)才是正確的,上面是自己亂寫的

};

var init = function(el,option){

var $el = $(el),

rating = $el.data('rating');

if(!rating){

$el.data('rating',(rating = new Rating(el,typeof option==="object"&&option)));

rating.init();

}


if(typeof option === 'string') rating[option]();

// this.$el.data('rating',rating);

// new Rating(el,options).init();

};

//JQ插件

$.fn.extend({

rating:function(option){

return this.each(function(){

init(this,option);

});

}

});

return{

init:init

?};

})();

$('#rating').rating({

mode:'quarter',

total:7,

num:4,

readOnly:false,

chosen:function(count,total){

$('#rating').rating('unbindEvent');

}

});

// rating.init('#rating',{

// ?total:10,

// ?num:3,

// ?readOnly:true,

// ?select:function(count,total){

// ?console.log("select的是"+this);

// ?console.log(count + '/' + total);

// ?},

// ?chosen:function(count,total){

// ?rating.init("#rating",'unbindEvent');

// ?},

// });

?

</script>

</html>


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

舉報(bào)

0/150
提交
取消

能不能把代碼貼出來,以方便學(xué)習(xí)?

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

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

幫助反饋 APP下載

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

公眾號(hào)

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