可以自定义图案的星级打分系统
XML/HTML Code
- <div class="container">
- <h4>Basic Example</h4>
- <div id="basic" style="font-size: 2em;"></div>
- <input type="text" readonly id="basicInput" class="form-control form-control-sm">
- <h4 class="mt-3">Half Stars</h4>
- <div id="half" style="font-size: 2em;"></div>
- <input type="text" readonly id="halfInput" class="form-control form-control-sm">
- <h4 class="mt-3">Custom Icons</h4>
- <div id="custom" style="font-size: 2em;"></div>
- <input type="text" readonly id="customInput" class="form-control form-control-sm">
- </div>
JavaScript Code
- <script>
- $("#basic").rating({
- "click": function (e) {
- console.log(e);
- $("#basicInput").val(e.stars);
- }
- });
- $("#half").rating({
- "half": true,
- "click": function (e) {
- console.log(e);
- $("#halfInput").val(e.stars);
- }
- });
- $("#custom").rating({
- stars: 7,
- emptyStar: "far fa-arrow-alt-circle-left",
- halfStar: "far fa-angry",
- filledStar: "fas fa-arrow-alt-circle-right",
- color: "#ff3ef9",
- half: true,
- "click": function (e) {
- console.log(e);
- $("#customInput").val(e.stars);
- }
- });
- </script>
原文地址:http://www.freejs.net/article_jquerywenzi_830.html