jQuery动态星级评分效果实现方法
本文实例讲述了jQuery动态星级评分效果实现方法。分享给大家供大家参考。具体如下:
这里的jQuery星级评分代码,是大家都很喜欢的功能,目前广泛应用,本星级评分加入了动画效果,注意,如果要真正实现星级评分,你需要动态程序配合,如ASP/PHP等,以便将评分值存入数据库。
运行效果如下图所示:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>jquery超漂亮星级评分</title><script type="text/javascript" src="jquery-1.6.2.min.js"></script><style>.user_rate {font-size:14px; position:relative; padding:10px 0;}.user_rate p {margin:0; padding:0; display:inline; height:40px; overflow:hidden; position:absolute; top:0; left:100px; margin-left:140px;}.user_rate p span.s {font-size:36px; line-height:36px; float:left; font-weight:bold; color:#DD5400;}.user_rate p span.g {font-size:22px; display:block; float:left; color:#DD5400;}.big_rate_bak {width:140px; height:28px; text-align:left; position:absolute; top:3px; left:85px; display:inline-block; background:url(http://files.jb51.net/file_images/article/201508/201586174000242.gif) left bottom repeat-x;}.big_rate_bak b {display:inline-block; width:24px; height:28px; position:relative; z-index:1000; cursor:pointer; overflow:hidden;}.big_rate_up {width:140px; height:28px; position:absolute; top:0; left:0; background:url(http://files.jb51.net/file_images/article/201508/201586174000242.gif) left top;}</style></head><body><div class="user_rate"> <div class="big_rate_bak"> <b rate="2" onclick="javascript:up_rate(20);"> </b> <b rate="4" onclick="javascript:up_rate(40);"> </b> <b rate="6" onclick="javascript:up_rate(60);"> </b> <b rate="8" onclick="javascript:up_rate(80);"> </b> <b rate="10" onclick="javascript:up_rate(100);"> </b> <div style="width:45px;" class="big_rate_up"></div> </div> <p><span id="s" class="s"></span><span id="g" class="g"></span></p></div><br><br>如果运行错误请刷新页面即可~</body><script type="text/javascript">$(function(){ get_rate(88);})function get_rate(rate){ rate=rate.toString(); var s; var g; $("#g").show(); if (rate.length>=3){ s=10; g=0; $("#g").hide(); }else if(rate=="0"){ s=0; g=0; }else{ s=rate.substr(0,1); g=rate.substr(1,1); } $("#s").text(s); $("#g").text("."+ g); $(".big_rate_up").animate({width:(parseInt(s)+parseInt(g)/10) * 14,height:26},1000); $(".big_rate_bak b").each(function(){ $(this).mouseover(function(){ $(".big_rate_up").width($(this).attr("rate") * 14 ); $("#s").text($(this).attr("rate")); $("#g").text(""); }).click(function(){ $("#f").text($(this).attr("rate")); $("#my_rate").show(); }) }) $(".big_rate_bak").mouseout(function(){ $("#s").text(s); $("#g").text("."+ g); $(".big_rate_up").width((parseInt(s)+parseInt(g)/10) * 14); })}function up_rate(rate){ $(".big_rate_up").width("0"); get_rate(rate);}</script></html>jQuery动态星级评分效果实现方法的更多相关文章
- jquery swiper3自定义切换效果的方法
jquery swiper3自定义切换效果的方法 <pre> <div class="swiper-slide"> <div class=" ...
- 纯css实现星级评分效果
效果 效果图如下,纯css实现超酷炫的星级评分动画效果 实现思路 5个类型为radio的input,label标签修改样式背景图为星星 label标签给每个星星鼠标停留时加注名字 点击星星有放大旋 ...
- jQuery动态五星评分
效果 css .star ul, .star li { list-style: none; } .star { position: relative; width: 600px; height: 24 ...
- js实现星级评分效果(非常规5个li代码)
1. 前言 此方案受到JS单行写一个评级组件启发,自己写了一个简单Demo. 功能有正常滑动,动态显示实心星星个数:当点击确认,则保持当前的实心星星个数:再移动时未点击,则离开后还是保持之前的状态. ...
- [学习笔记]jQuery实现一些动画效果的方法
jQuery实现效果的方法 1,隐藏和显示:hide(),show(),toggle() // [ˈtɑ:gl]切换 语法: $(selector).hide(speed,callback); $( ...
- jquery实现星级评分
项目中遇到到实现星级评分,就用了这个插件 http://www.jq22.com/jquery-info291
- jQuery用户数字评分效果
效果预览:http://hovertree.com/texiao/jquery/5.htm HTML文件代码: <!DOCTYPE html> <html xmlns="h ...
- jQuery Raty 星级评分
在线实例 实例演示 使用方法 <div id="star"></div> 复制 $('#star').raty(); 复制 你只需要有一个 div构建Rat ...
- jquery动态加载JS【方法getScript】的改进
http://www.cnblogs.com/cuitsl/archive/2012/11/15/2771549.html
随机推荐
- 【划分树+二分】HDU 4417 Super Mario
第一次 耍划分树.. . 模板是找第k小的 #include <stdio.h> #include <string.h> #include <stdlib.h> # ...
- apk签名相关文章
签名详解:https://stackoverflow.com/questions/4245303/android-sf-file 使用不同的keystore,签名后生成SF文件一模一样正常吗? 正常 ...
- 系统学习NIO
概述 适用于有一定编程基础的朋友,想系统学习NIO这块知识的朋友.知识点大体分3块:1:>概念了解(各类IO) 2>NIO的核心(缓存区,通道等) 3>网络IO 详细 代码下载:ht ...
- Ubuntu分区方案归总
更新时间:2010-8-26 一.各文件及文件夹的定义 /bin:bin是binary(二进制)的缩写.存放必要的命令 存放增加的用户程序. /bin分区,存放标准系统实用程序. /boot: ...
- TensorFlow 安装 Ubuntu14.04
1.Install pip (or pip3 for python3) if it is not already installed: # Ubuntu/Linux 64-bit $ sudo apt ...
- 使用spring AOP获得session的思路
由于Spring 的AOP面向切面编程,与Servlet容器没有任何关联,所以想要获得Session会话比较麻烦. 当然Struts2同样不依赖Servlet容器,可以在Spring AOP中可以使用 ...
- 四种对象生存期和作用域、static 用法总结
一.四种对象生存期和作用域 栈对象 隐含调用构造函数(程序中没有显式调用) 堆对象 隐含调用构造函数(程序中没有显式调用),要显式释放 全局对象.静态全局对象 全局对象的构造先于main函数 已初始化 ...
- 【iOS开发-25】UIDevice查看系统信息,从一个问题開始怎样高速找到自己想要的属性和方法并看懂它
如果须要解决的问题:写代码时遇到一种情况,就是须要推断iOS版本号,可能低版本号和高版本号须要增减一些代码,此时.怎样推断iOS版本号? (1)第一步.当然度娘.输入"iOS 推断系统版本号 ...
- Mysql 字符串函数 详解
字符串函数是最常用的一种函数了,如果大家编写过程序的话,不妨回过头去看看自己使用过的函数,可能会惊讶地发现字符串处理的相关函数占已使用过的函数很大一部分.MySQL中字符串函数也是最丰富的一类函数,表 ...
- CentOS 5.4 安装和卸载桌面
显示系统已经安装的组件,和可以安装的组件:#yum grouplist 如果系统安装之初采用最小化安装,没有安装xwindow,那么先安装:#yum groupinstall "X Wind ...