PB点赞后再次进入显示已赞效果

[复制链接]
查看1545 | 回复0 | 2021-10-31 08:25 | 显示全部楼层 |阅读模式
PbootCMS点赞后再次进入显示已赞效果
本操作需要下载附件引入相关js才能实现哦
引入后到详情页面使用,如果需要在列表页面使用,可以适当修改相关参数
注意文件引用路径,本教程使用的是根目录路径哦,如果是模板路径使用PB相应标签即可,有疑问欢迎艾特我哦
html部分
  1. .likes a {
  2.   height: 40px;
  3.   line-height: 40px;
  4.   display: inline-block;
  5.   padding: 0 15px;
  6.   background: #fff;
  7.   border: 1px solid #4fc08d;
  8.   color: #4fc08d;
  9.   border-radius: 30px;
  10.   transition: all .5s;
  11.   -webkit-transition: all .5s;
  12. }

  13. .likes a.active, .likes a:hover {
  14.     background: #4fc08d;
  15.     color: #fff;
  16.     transition: all .5s;
  17.     -webkit-transition: all .5s;
  18. }

  19. .likes a span {
  20.   text-align: center;
  21.   margin: 0 3px;
  22. }

  23. .likes-tip {
  24.   position: absolute;
  25.   top: -45px;
  26.   left: 50%;
  27.   margin-left: -45px !important;
  28.   margin-right: 0px !important;
  29.   width: 90px;
  30.   height: 30px;
  31.   line-height: 30px;
  32.   background: #4fc08d;
  33.   border-radius: 3px;
  34.   color: #fff;
  35.   font-size: 14px;
  36.   display: none;
  37. }

  38. .likes .zan:hover .likes-tip {
  39.   display: block;
  40. }
  41. </style>
复制代码
js部分
  1. <script src="/libs/js/jQuery.cookie.js"></script>
  2. <script>
  3. var Like_status = jQuery.cookie('likes_{content:id}');
  4. if( Like_status == 1 ){
  5.   $('.zan-text').empty().append('已赞');
  6.   $('.zan').addClass('active');
  7.   jQuery('.zan').append('<span class="tac likes-tip">您已点赞!</span>');
  8.   jQuery('.like-link').removeAttr('href');
  9. }
  10. </script>
复制代码
PB相关附件下载如下:
jQuery.cookie.zip (1.44 KB, 下载次数: 0, 售价: 1 丢币)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则