自定义图像 轻量级评级系统 jQuery Rates

  • 源码大小:266.36KB
  • 所需积分:1积分
  • 源码编号:19JP-3794
  • 浏览次数:1158次
  • 最后更新:2023年07月23日
  • 所属栏目:其他
本站默认解压密码:19jp.com 或 19jp_com

简介

rates是一个简单而轻量级的jQuery评级插件,供您在网站上使用,它具有高度的可定制性,允许用户对页面上的不同元素进行评级。

它允许您使用任何图像作为评级符号,并将评级值保存在隐藏的输入字段中

如何使用它:

1.在文档中加载样式表rates.css和JavaScript rates.js。

  1. <!-- jQuery is required -->
  2. <script src="/path/to/cdn/jquery.slim.min.js"></script>
  3. <!-- Themes -->
  4. <link rel="stylesheet" href="css/rates.css" />
  5. <!-- Rates plugin -->
  6. <script src="js/jquery-rates.js"></script>

2.创建一个空容器,插件在其中生成一个评级系统。

  1. <div id="demo"></div>

3.初始化插件以生成如下基本评级系统:

  1. $('#demo').rates({
  2. // options here
  3. });
  1. <!-- Output HTML -->
  2. <div id="demo" class="rates-container">
  3. <input type="hidden" id="demoRating" name="demoRating" value="0">
  4. <img src="images/white-star.png" class="" style="height: 25px;">
  5. <img src="images/white-star.png" class="" style="height: 25px;">
  6. <img src="images/white-star.png" class="" style="height: 25px;">
  7. <img src="images/white-star.png" class="" style="height: 25px;">
  8. <img src="images/white-star.png" class="" style="height: 25px;">
  9. </div>

4.自定义评级符号。

  • 白色星形
  • 黑色恒星
  • 白心
  • 黑心材
  • 或者使用你自己的形象。
  1. $('#demo').rates({
  2. shape: 'black-heart',
  3. });

5.自定义填充颜色。

  • 费率为黄色
  • 绿色费率
  • 费率为红色
  • 费率为蓝色
  • 或者使用你自己的风格。
  1. $('#demo').rates({
  2. shadeColor: 'rates-green',
  3. });

6.确定要生成的评级符号的数量。默认值:5。

  1. $('#demo').rates({
  2. shapeCount: 10,
  3. });

7.设置评级符号的大小。默认值:“25px”。

  1. $('#demo').rates({
  2. shapeHeight: '50px',
  3. });

8.覆盖默认的图像文件夹。

  1. $('#demo').rates({
  2. imagesFolderLocation: '',
  3. });

预览截图