js 选项卡 【鼠标悬停标题,显示对应内容,改变其他标题颜色并隐藏内容】
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="divSliding.aspx.cs" Inherits="WebDemoList.divSliding" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head id="Head1" runat="server"> <title>无标题页</title> <link href="CSS.css" rel="stylesheet" type="text/css" /> <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script language="javascript" type="text/javascript"> $(document).ready(function () { setTab('Label', 1, 7) }); function setTab(name, cursel, n) { for (i = 1; i <= n; i++) { var menu = document.getElementById(name + i); var con = document.getElementById("con_" + name + "_" + i); if (cursel == 1) { document.getElementById("label1").style.color = "red"; document.getElementById("label2").style.color = "black"; document.getElementById("label3").style.color = "black"; document.getElementById("label4").style.color = "black"; document.getElementById("label5").style.color = "black"; document.getElementById("label6").style.color = "black"; document.getElementById("label7").style.color = "black"; } else if (cursel == 2) { document.getElementById("label1").style.color = "black"; document.getElementById("label2").style.color = "red"; document.getElementById("label3").style.color = "black"; document.getElementById("label4").style.color = "black"; document.getElementById("label5").style.color = "black"; document.getElementById("label6").style.color = "black"; document.getElementById("label7").style.color = "black"; } else if (cursel == 3) { document.getElementById("label1").style.color = "black"; document.getElementById("label2").style.color = "black"; document.getElementById("label3").style.color = "red"; document.getElementById("label4").style.color = "black"; document.getElementById("label5").style.color = "black"; document.getElementById("label6").style.color = "black"; document.getElementById("label7").style.color = "black"; } else if (cursel == 4) { document.getElementById("label1").style.color = "black"; document.getElementById("label2").style.color = "black"; document.getElementById("label3").style.color = "black"; document.getElementById("label4").style.color = "red"; document.getElementById("label5").style.color = "black"; document.getElementById("label6").style.color = "black"; document.getElementById("label7").style.color = "black"; } else if (cursel == 5) { document.getElementById("label1").style.color = "black"; document.getElementById("label2").style.color = "black"; document.getElementById("label3").style.color = "black"; document.getElementById("label4").style.color = "black"; document.getElementById("label5").style.color = "red"; document.getElementById("label6").style.color = "black"; document.getElementById("label7").style.color = "black"; } else if (cursel == 6) { document.getElementById("label1").style.color = "black"; document.getElementById("label2").style.color = "black"; document.getElementById("label3").style.color = "black"; document.getElementById("label4").style.color = "black"; document.getElementById("label5").style.color = "black"; document.getElementById("label6").style.color = "red"; document.getElementById("label7").style.color = "black"; } else if (cursel == 7) { document.getElementById("label1").style.color = "black"; document.getElementById("label2").style.color = "black"; document.getElementById("label3").style.color = "black"; document.getElementById("label4").style.color = "black"; document.getElementById("label5").style.color = "black"; document.getElementById("label6").style.color = "black"; document.getElementById("label7").style.color = "red"; } con.style.display = i == cursel ? "block" : "none"; } } </script> </head> <body> <form id="form1" runat="server"> <center> <div class="xinwen"> <br /> <asp:Label ID="Label1" runat="server" Text="一" onmouseover="setTab('Label',1,7)" ></asp:Label> <asp:Label ID="Label2" runat="server" Text="二" onmouseover="setTab('Label',2,7)" ></asp:Label> <asp:Label ID="Label3" runat="server" Text="三" onmouseover="setTab('Label',3,7)" ></asp:Label> <asp:Label ID="Label4" runat="server" Text="四" onmouseover="setTab('Label',4,7)" ></asp:Label> <asp:Label ID="Label5" runat="server" Text="五" onmouseover="setTab('Label',5,7)" ></asp:Label> <asp:Label ID="Label6" runat="server" Text="六" onmouseover="setTab('Label',6,7)" ></asp:Label> <asp:Label ID="Label7" runat="server" Text="七" onmouseover="setTab('Label',7,7)" ></asp:Label> <div id="con_Label_1" style="float:left;"> <div style="float:left;">111</div> </div> <div id="con_Label_2" style="float:left;"> <div style="float:left;">222</div> </div> <div id="con_Label_3" style="float:left;"> <div style="float:left;">333</div> </div> <div id="con_Label_4" style="float:left;"> <div style="float:left;">444</div> </div> <div id="con_Label_5" style="float:left;"> <div style="float:left;">555</div> </div> <div id="con_Label_6" style="float:left;"> <div style="float:left;">666</div> </div> <div id="con_Label_7" style="float:left;"> <div style="float:left;">777</div> </div> </div> </center> </form> </body> </html>