选项卡切换

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="jquery-1.4.3.min.js" type="text/javascript"></script>
    <script type="text/javascript">
$(function()
{
   $("#tabBackground li").each(function() { 
     $(this).click(function() {
     var index=$(this).index("li");//得到选择的选项的Index
     $(this).siblings(".tabBackgroundActive").removeClass("tabBackgroundActive");//移除当前选择的样式
     $("li:eq("+index+")").addClass("tabBackgroundActive");                      //给当前选择的样式添加样式
     $(".divBackground.divContentActive").removeClass("divContentActive");       //将内容删除掉
     $(".divBackground:eq("+index+")").addClass("divContentActive")              //将选项卡对应的内容添加样式
     })
   })
}
)
    </script>


    <style type="text/css">
        #tab
        {
            width: 300px;
            margin: 0 auto;
        }
        ul
        {
            list-style: none;
        }
        li
        {
            float: left;
            width: 50px;
            height: 25px;
            margin: 0 auto;
            text-align: center;
            padding-top: 5px;
            margin-right: 10px;
            background-color: #D3E0F2;
            color: #15428B;
            cursor: pointer;
            border-top-left-radius: 5px;
            border-top-right-radius: 5px;
            border: 0px solid #15428B;
        }
        .tabBackgroundActive
        {
            background-color: #DEECFD;
            border: 1px solid red;
            color: red;
            border-bottom: 0px solid red;
        }
        .divBackground
        {
            clear: both;
            margin: 0 auto;
            background-color: #DEECFD;
            width: 220px;
            height: 200px;
            display: none;
            border-radius: 10px;
            text-align: center;
            padding-top: 10px;
            border: 1px solid red;
        }
        .divContentActive
        {
            display: block;
            position: absolute;
            z-index: -1;
            margin-top: 30px;
            border: 1px solid red;
        }
    </style>
</head>
<body>
    <div id="tab">
        <ul id="tabBackground">
            <li class="tabBackgroundActive">tab A</li>
            <li>tab B</li>
            <li>tab C</li>
        </ul>
        <div class="divBackground divContentActive">
            tab 1 content
        </div>
        <div class="divBackground">
            tab 2 content
        </div>
        <div class="divBackground">
            tab 3 conetent
        </div>
    </div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值