layui中提供了rate组件,用法很简单,直接上代码。

<div ></div>
    <script>
        layui.use('rate', function () {
            var rate = layui.rate;
            var ins1 = rate.render({
                elem: '#test1'         //绑定元素
                , length: 5            //星星个数
                , value: 3             //初始化值
                , theme: '#000099'     //颜色
                , half: true           //支持半颗星
                , text: true           //显示文本,默认显示 '3.5星'
                , readonly: false      //只读
                //自定义文本,点击后文本显示的内容
                , setText: function (value) {
                    if (value < 2) {
                        this.span.text("差")
                    } else if (value <= 4) {
                        this.span.text("一般")
                    } else {
                        this.span.text("好")
                    }
                }
                //选定时调用,评分时发送一个ajax,readonly设为true
                , choose: function (value) {
                    if (value > 4) alert('么么哒')
                }
            });
        });
    </script>

 注:本文只是自己为了查看方便整理的一些内容,并不包含layui中提供的所有内容,查看更多请访问官网http://www.layui.com/doc/modules/upload.html

相关文章:

  • 2021-05-27
  • 2021-09-14
  • 2021-11-20
  • 2021-11-29
  • 2021-09-16
  • 2021-07-11
  • 2021-05-08
  • 2022-02-21
猜你喜欢
  • 2021-10-08
  • 2021-11-12
  • 2021-08-28
  • 2022-02-01
  • 2021-09-25
  • 2022-03-02
  • 2022-01-09
相关资源
相似解决方案