用jquery怎么实现点击一栏目实现栏目变色,再点击另一栏目也变色,但原来的变回原色

用jquery怎么实现点击一栏目实现栏目变色,再点击另一栏目也变色,但原来的变回原色,第1张

效果:

代码:

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
<style>
ul li{
    float:left;
    width: 110px;
    margin: 0 5px;
    background-color:#fff;
    border:1px solid #000;
    line-height:25px;
    list-style: none;
    text-align: center;
    font-size:14px;
    font-family:'微软雅黑';
    cursor: pointer;
    color:#000;
    font-weight:bold;
}
ul li:hover,ul liselected{
    background-color:#000;
    color:#fff;
}
</style>
<script src=">我根据你的情况是这么做的,点击首页的时候,首页的字体颜色改变,订单和会员中心的字体颜色还原;
点击订单的时候,订单的字体颜色改变,首页和会员中心中心的字体颜色还原;
点击会员中心的时候,会员中心的字体颜色改变,首页和订单的字体颜色还原;
因为你没有给首页、订单和会员中心的,所以我也没有去切图什么的,只做好了字体颜色的改变,你稍后看懂了直接将背景的颜色添加上去即可,下面就是我的样式和内容:
<style>
ul li{list-style: none;width:200px;height:40px;line-height: 40px;text-align: center; }
a{text-decoration:none;color:#fff;font-size: 20px;}
aa{background:#777;}
bb{background: #888}
cc{background: #999}
aa1:focus{color:#000;}
aa1:focus bb1{color:#fff;}
aa1:focus cc1{color:#fff;}
bb1:focus{color:#000;}
bb1:focus aa1{color:#fff;}
bb1:focus cc1{color:#fff;}
cc1:focus{color:#000;}
cc1:focus aa1{color:#fff;}
cc1:focus bb1{color:#fff;}
</style>
<body>

<div class="foot">
<ul>
<li class="aa">
<a href="#" class="aa1">
<div class="pic"><img src="" alt=""></div>
<div class="tit">首页</div>
</a>
</li>
<li class="bb">
<a href="#" class="bb1">
<div class="pic"><img src="" alt=""></div>
<div class="tit">订单</div>
</a>
</li>
<li class="cc">
<a href="#" class="cc1">
<div class="pic"><img src="" alt=""></div>
<div class="tit">会员中心</div>
</a>
</li>
</ul>
</div>
</body>

a:link {color: #FF0000} / 未访问的链接 /
a:visited {color: #00FF00} / 已访问的链接 /
a:hover {color: #FF00FF} / 鼠标移动到链接上 /
a:active {color: #0000FF} / 选定的链接 /
希望能帮上LZ~

在form中添加一个按钮,一个combobox,combo1的style属性调成2,完成后粘贴如下代码,运行。移动鼠标到按钮上面看效果,点击列表框换颜色。
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X > 15 And X < Command1Width - 15 And Y > 15 And Y < Command1Height - 15 Then
Form1Caption = "按钮是" & Combo1List(Combo1ListIndex) & "色的"
Command1BackColor = Combo1ItemData(Combo1ListIndex)
Else
Form1Caption = "没变"
Command1BackColor = &H8000000F
End If
End Sub
Private Sub Form_Load()
Combo1AddItem "红"
Combo1AddItem "绿"
Combo1AddItem "黄"
Combo1AddItem "蓝"
Combo1AddItem "白"
Combo1ItemData(0) = vbRed
Combo1ItemData(1) = vbGreen
Combo1ItemData(2) = vbYellow
Combo1ItemData(3) = vbBlue
Combo1ItemData(4) = vbWhite
Combo1ListIndex = 0
Command1Left = Form1Width / 4
Command1Top = Form1Height / 4
Command1Width = Form1Width / 3
Command1Height = Form1Height / 3
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X < Command1Left Or X > Command1Left + Command1Width Or Y < Command1Top Or Y > Command1Top + Command1Height _
Then Command1BackColor = &H8000000F: Form1Caption = "没变"
End Sub

td单元格变色,只用简单的js代码即可实现。
很简洁的代码,点击即可运行该代码
<body>
<table border="1px">
<tr>
<th id="id_item1" οnmοuseοver="thisbgColor='green'" οnmοuseοut="thisbgColor=''">Menu Item1</th>
</tr>
<tr>
<th>Menu Item2</th>
</tr>
</table>
</body>

1、打开excel文件后,将工作表表格全部选中。

2、然后在条件格式菜单下,点击“新建规则”。

3、选择最后一个规则类型,输入公式=(cell("row")=row())(cell("col")=column()),点击格式按钮。

4、然后设置表格的填充颜色,进行确定。

5、返回主设置界面后,再点击确定按钮。

6、然后按下“ALt+F11”打开VBA编辑界面,输入下图中的代码。

7、关闭VBA界面,回到Excel界面。鼠标点击那个表格,哪个就会变色。

1、首先,打开HTML编辑器并创建一个新的HTML文件,比如indexhtml。

2、在indexhtml中的<style>标签中,输入css代码:button {background-color: #00a7d0}

button:hover {background-color: #ff7701}。

3、当浏览器运行索引indexhtml页面中,出现蓝色背景颜色的按钮。

4、将鼠标移到按钮上,按钮的背景颜色将变为橙色。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/yw/13377990.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-24
下一篇 2023-07-24

发表评论

登录后才能评论

评论列表(0条)

保存