zoukankan      html  css  js  c++  java
  • jquery tab选项卡

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>选项卡效果</title>
    <script type="text/javascript" src="js/jquery-1.7b2.js"></script>
    <script type="text/javascript">
          $(document).ready(function(){  //页面加载时
             $('.ct:gt(0)').hide();
            var hwd=$('.box ul li');
            /*hwd.hover(function(){  //鼠标移上去背景变化,hover事件
                $(this).addClass('two')
                .siblings().removeClass();   //删除兄弟节点
            });*/
            hwd.hover(function(){
                 $(this).addClass('one')//向匹配的元素添加指定的类名。
                 .siblings().removeClass();
            var hwd_index=hwd.index(this);//搜索匹配的元素,并返回相应元素的索引值,从0开始计数。
            //alert(hwd_index);
            $('.ct').eq(hwd_index).show().siblings().hide();
            });
        
        });
    </script>
    <style>
    *{ padding:0px; margin:0px;}
    body{ font-size:12px; padding:100px;}
    ul{ list-style-type:none;}
    .box ul{ height:30px; line-height:30px;}
    .box ul li{ float:left; padding:0 10px;cursor:pointer; position:relative; background:url(images/bg1.png) repeat-x; border:1px solid #dbe2e7; margin-right:5px; border-bottom:none;}
    .content{ 325px; border:1px solid #dbe2e7; padding:10px;}
    * html.content{ margin-top:-1px;}
    .box ul li.one{ background:#fff; }
    .box ul li.two{ background:orange;}
    </style>

    </head>

    <body>
    <div class="box">
    <ul>
    <li class="one">菜单一</li>
    <li>菜单二</li>
    <li>菜单三</li>
    </ul>
    <div class="content">
    <div class="ct">菜单一的内容</div>
    <div class="ct">菜单二的内容</div>
    <div class="ct">菜单三的内容</div>
    </div>
    </div>
    </body>
    </html>
    效果:

  • 相关阅读:
    linux安装java环境
    前端JS-websocket与后端通信
    windows安装NodeJS/修改全局路径/配置镜像站
    vue基础---13vue-router
    uni-app项目
    vue基础---12脚手架
    vue基础---11组件
    vue基础---10生命周期
    vue基础---09表单输入绑定
    vue基础---08事件
  • 原文地址:https://www.cnblogs.com/cwl168/p/3795836.html
Copyright © 2011-2022 走看看