html button 按钮单选且 高亮

<DIV class="middle">

<div class="containerTarget">

<span class="hover-target1" οnclick="btn(1);">韵达 </span>

<span class="hover-target2" οnclick="btn(2);">中通 </span>

<span class="hover-target3" οnclick="btn(3);">圆通 </span>

</div>

</DIV>

function go_savebtn(e) {

if (e == '1') {

if (document.querySelector(".hover-target1")) {

document.querySelector(".hover-target1").className = 'hover-static1'

}

else {

document.querySelector(".hover-static1").className = 'hover-target1'

}

} else if (e == '2') {

if (document.querySelector(".hover-target2")) {

document.querySelector(".hover-target2").className = 'hover-static2'

}

else {

document.querySelector(".hover-static2").className = 'hover-target2

}

} else if (e == '3') {

if (document.querySelector(".hover-target3")) {

document.querySelector(".hover-target3").className = 'hover-static3'

} else {

document.querySelector(".hover-static3").className = 'hover-target3'

}

}

}

.hover-target1,

.hover-target2,

.hover-target3 {

cursor: pointer;

background-color: #fff(64, 158, 255, 1);

color: #000;

}

.hover-static1,

.hover-static2,

.hover-static3 {

cursor: pointer;

background-color: rgba(64, 158, 255, 1);

color: white;

}

.hover-target1:hover,

.hover-target2:hover,

.hover-target3:hover {

cursor: pointer;

background-color: rgba(64, 158, 255, 1);

color: white;

border-radius: 5px;

border: 1px solid #ccc;

width: 136px;

height: 40px;

}

相关推荐
Avan_菜菜16 小时前
AI 能写代码了,为什么我反而开始要求它先写文档?
前端·github·ai编程
JieE21220 小时前
LeetCode 226. 翻转二叉树|JS 递归超详细拆解,二叉树入门经典题
javascript·算法
JieE21220 小时前
LeetCode 104. 二叉树的最大深度|递归思路超详细拆解
javascript·算法
爱勇宝21 小时前
鸿蒙生态的下半场:开发者不只要能开发,还要能赚钱
android·前端·程序员
IT_陈寒1 天前
SpringBoot这个自动配置坑我跳了三次
前端·人工智能·后端
kyriewen1 天前
我用 AI 一周写完了整个项目,上线第一天就崩了——这是我踩过最贵的 5 个坑
前端·javascript·ai编程
Larcher1 天前
AI Loop:让AI像人一样自主完成任务的核心机制
javascript·人工智能·设计模式
默_笙1 天前
🃏 JS 只有 8 种数据类型,但我花了 2 天才搞懂 null 和 undefined 的区别
javascript
牧艺1 天前
从零到协同:构建类飞书在线文档系统的五个技术重难点
前端·人工智能
jump_jump1 天前
流式 HTML:从 htmx 片段装配到浏览器原生增量渲染
javascript·性能优化·前端工程化