项目中经常会遇见评价功能,下边总结了两种项目中遇见的写法,也许会有更好的写法,一起探索
一:使用插件(jquery.raty.min.js)
html写法
-
<div id="guide_rating" class="rating" style="cursor: pointer;"></div>
js写法
-
$('#guide_rating').raty({
-
'scoreName': 'appointment[guide_rating]',
-
'score' : 4,
-
'cancel' : false,
-
'half': true,
-
'starType' : 'i'
-
})
css写法
-
.cancel-on-png,
-
.cancel-off-png,
-
.star-on-png,
-
.star-off-png,
-
.star-half-png {
-
font-size: 26px;
-
}
-
.cancel-on-png,
-
.cancel-off-png,
-
.star-on-png,
-
.star-off-png,
-
.star-half-png {
-
-moz-osx-font-smoothing: grayscale;
-
-webkit-font-smoothing: antialiased;
-
font-family: "FontAwesome";
-
font-style: normal;
-
font-variant: normal;
-
font-weight: normal;
-
line-height: 1;
-
speak: none;
-
text-transform: none;
-
color: #777777;
-
}
-
.cancel-on-png {
-
color: #dd5a43;
-
}
-
.cancel-on-png:before {
-
content: "\f057";
-
}
-
.cancel-off-png {
-
color: #e08374;
-
}
-
.cancel-off-png:before {
-
content: "\f05c";
-
}
-
.star-on-png {
-
color: #ea5404;
-
}
-
.star-on-png:before {
-
content: "\f005";
-
}
-
.star-off-png {
-
color: #777777;
-
}
-
.star-off-png:before {
-
content: "\f006";
-
}
-
.star-half-png {
-
color: #ea5404;
-
}
-
.star-half-png:before {
-
content: "\f123";
-
}
二:用js直接写,不使用插件
html写法
-
<div id="xzw_starSys" class="evaluationInfoBox pb30" style="width:100%">
-
<div class="xzw_starBox">
-
<span class="starDes">区域</span>
-
<ul class="star" id="star0">
-
<li><a href="javascript:void(0)" title="1" class="one-star">1</a></li>
-
<li><a href="javascript:void(0)" title="2" class="two-stars">2</a></li>
-
<li><a href="javascript:void(0)" title="3" class="three-stars">3</a></li>
-
<li><a href="javascript:void(0)" title="4" class="four-stars">4</a></li>
-
<li><a href="javascript:void(0)" title="5" class="five-stars">5</a></li>
-
</ul>
-
<div class="current-rating" id="showb0" style="width: 24px;"></div>
-
</div>
-
<div class="clearfix"></div>
-