感谢提前帮助。
我对Javascript并不友好...
我有一个五星级评论系统,我试图获得评级的价值(按1到5的等级)并将其推入隐藏的表格输入中。
关于&#34的任何信息;如何获得' XXXXX'空间"将不胜感激。
谢谢:)
这里是代码:)
var rating = {
init: function() {
var ratingWidth = $('.rating-select span').width();
var step = ratingWidth / 5;
$('.rating-select').mousemove(function(e) {
var x = e.pageX - $(this).offset().left;
x = Math.ceil(x / step) * step;
$('.rating-select span span').width(x);
$(this).data('rating', x/step);
});
$('.rating-select').mouseleave(function(e) {
var newWidth = $(this).find('select').val();
$('.rating-select span span').width(newWidth*step);
});
$('.rating-select').click(function(e) {
e.preventDefault();
$(this).find('select').val($(this).data('rating'));
document.getElementById("hiddenForm").value = /* VALUE */;
});
}
};

.rating {
color: #ca293e;
margin-bottom: 10px;
letter-spacing: 5px;
}
.rating.rating-select {
cursor: pointer;
}
.rating > span {
position: relative;
overflow: hidden;
}
.rating > span:before {
content: "\f006\f006\f006\f006\f006";
font-family: 'fontAwesome' !important;
margin-right: -5px;
}
.rating > span span {
position: absolute;
left: 0;
top: 0;
height: 100%;
line-height: 25px;
}
.rating > span span:after {
content: "\f005\f005\f005\f005\f005";
position: absolute;
top: -3px;
left: 0;
font-family: 'fontAwesome' !important;
width: 100%;
margin-right: -5px;
overflow: hidden;
white-space: nowrap;
}

<div class="rating rating-select">
<span><span></span></span>
<select>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
&#13;
Thansk寻求帮助:)
答案 0 :(得分:0)
尝试使用jQuery Raty插件,它是为此而设计的,并且它非常易于使用。
通过这种方式,您可以通过这种方式获得分数:
<div id="raty1"></div>
<script>
$('#raty1').raty({
click: function(score, evt) {
alert('ID: '+this.id+' Score: '+score);
}
});
</script>