效果:

HTML:

<div class="rightBtn cur">+关注</div>

CSS:

.rightBtn{
width: 80px;
height: 30px;
background: rgba(200, 200, 200, 1);/*灰色*/
color: #fff;
text-align: center;
line-height: 30px;
border-radius: 2px;
cursor: pointer;
}
.cur {
background: #FB452F;
}
.rightBtn:hover {
background: #FF5844;
}
.cur:hover {
background: #FF5844;
}

JS:

$(".rightBtn").click(function(){
let flag=$(this).hasClass("hh");
if(flag){
$(this).text("+关注")
$(this).addClass("cur")
$(this).removeClass("hh")
}else{
// $(this).addClass()
$(this).text("已关注")
$(this).addClass("hh")
$(this).removeClass("cur")
}
})
$(".rightBtn").mouseover(function(){
let flag=$(this).hasClass("hh");
console.log(flag,888)
if(flag){
$(this).text("取消关注")
}else{
$(this).text("+关注")
}

})
$(".rightBtn").mouseout(function(){
let flag=$(this).hasClass("hh");
if(flag){
$(this).text("已关注")
}
})

JS:代码截图,便于看代码

最新文章

  1. 作业一:android开发平台的演变以及Android Studio设置
  2. multiOTP配置安装
  3. 我的c++学习(8)运算符重载和友元
  4. https的工作流程
  5. ios 从微信返回自己的app
  6. Jmeter软件测试2--http接口测试
  7. Java设计模式之《观察者模式》及应用场景
  8. mybatis基础学习3---特殊sql语句(备忘)
  9. Spring-cloud(四)服务发现与消费:ribbon的使用
  10. getParameter的用法总结
  11. Itellij Idea全局搜索
  12. 【洛谷P1018】乘积最大 dp+高精度
  13. python 读csv格式的文件
  14. Linux下的一些名词解释
  15. Oracle物化视图的一般使用
  16. python的N个小功能(更新文件)
  17. CCD与CMOS的区别
  18. 通过Intel XDK编写跨平台app(一)
  19. Ubuntu相关命令
  20. 解决大于 4GB 的 Windows 10 镜像在 UEFI 模式下的安装问题

热门文章

  1. Java内存模型(二)volatile底层实现(CPU的缓存一致性协议MESI)
  2. nginx加php(一)
  3. Git 发生Another git process seems to be running in this repository, e.g. an editor opened by &#39;git commit&#39;.错误
  4. 洛谷 P1268 树的重量 题解
  5. golang强制类型转换
  6. python-day30(正式学习)
  7. C语言经典100例(51-100)
  8. Thinkphp5.0上传图片与运行python脚本
  9. MySQL数据库基础-JAVA
  10. qt webengineview 设置背景颜色