基于jQuery实现星级评分效果
仿照『口碑』的评星级效果做的一点小东西,测试下自己这段时间的学习成果···
看图知效果:

预览效果:星级评分
下载文件:star-Level.rar
口碑的代码:starLevel-koubei.rar[提取自口碑网]
html
- <div class="selectStar">
- <ul class="clearfix">
- <li>
- <span class="red">*</span>
- <span class="zi">服务 </span>
- <span id="dpCont1" class="dpCont"></span>
- <em id="dpStar1" class="">
- <a href="#" id="1">1</a>
- <a href="#" id="2">2</a>
- <a href="#" id="3">3</a>
- <a href="#" id="4">4</a>
- <a href="#" id="5">5</a>
- </em>
- </li>
- </ul>
- </div>
javascript:
- $(function(){
- var className;
- var classID;
- var dpText="";
- var dpTextC="";
- $(".selectStar em a").bind("click",function(){
- className = "selectS" + $(this).attr("id");
- classID = $(this).parent().attr("id");
- $(this).parent().removeClass().addClass(className);
- if($(this).attr("id") == 1 || $(this).attr("id") == 2) {dpTextC = "差评";}
- if($(this).attr("id") == 3 || $(this).attr("id") == 4) {dpTextC = "中评";}
- if($(this).attr("id") == 5) {dpTextC = "好评";}
- $(this).parent().prev(".dpCont").text(dpTextC);
- return false;
- })
- .bind("mouseover",function(){
- if($(this).attr("id") == 1 || $(this).attr("id") == 2) {dpText = "差评";}
- if($(this).attr("id") == 3 || $(this).attr("id") == 4) {dpText = "中评";}
- if($(this).attr("id") == 5) {dpText = "好评";}
- $(this).parent().removeClass().addClass("selectS" + $(this).attr("id"));
- $(this).parent().prev(".dpCont").text(dpText);
- })
- .bind("mouseout",function(){
- $(this).parent().removeClass("selectS" + $(this).attr("id"));
- if($(this).parent().attr("id") == classID){
- $(this).parent().addClass(className);
- }
- $(this).parent().prev(".dpCont").text(dpTextC);
- });
- });
标签:JQuery
hmm… interesting thoughts.
[回复]
怎么用?

[回复]
我想在 123.php页面获取用户评分值,存入是数据库。我该如何获取评分值呢????
[回复]
你可以弄个隐藏域,当评级状态改变的时候随之改变。
然后php获取这个隐藏域的值,就很简单了
[回复]
有一个问题
我在asp.net项目中只有第一个框框有效
多个后面的都无效~~
[回复]
注意下代码中的ID,ID是不能重复的。dpCont1、dpStar1。
[回复]
有个问题,点击后,鼠标再去划过选项。
除了最后次点击的选中外,其他的都清空了。评论语也显示为最后次点击的评论语。
该如何解决?
[回复]
[回复]
能不能让一个评论者只评论一次? 能的话就用了? 我想拿去直接使用~
[回复]
这个需要后端的支持!
[回复]