zoukankan      html  css  js  c++  java
  • 多选项卡切换原理

    <!doctype html>
    <html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>多选项卡切换原理</title>
        <meta name="keywords" content="" />
        <script type="text/javascript" src="../jquery-1.8.2.js"></script>
        <style type="text/css">        
            #main{width:500px;height:200px;font-size:12px;color:#000000;}
            #main #tagsBox{margin-left:10px;}
            #main #tagsBox h3{width:80px; height:25px; background:#C1D8ED; text-align:center; line-height:25px; float:left; margin:0px 2px 0px 0px;}
            #main #tagsBox h3 a{color:#666666; text-decoration:none;}        
            #main #tagsBox .selectedTagCls{background:#8BBCE5;}
            #main #tagsBox .itemTitle{color:#000000;}
            #main #contentBox{width:500px; height:175px; float:left; background:#8BBCE5; overflow-y:auto;}
        </style>
        <script type="text/javascript">
            $(function(){
                    //初始先加载第一个选项内容
                    $('#content').load($('#main #tagsBox h3:eq(0) a:eq(0)').attr('href'));
                    //如果遇到被点击情况,返回false
                    $('#main #tagsBox h3').click(function(){
                        return false;
                    });
                    //下面对选项卡鼠标移入样式控制
                    $('#main #tagsBox h3').mouseover(function(){
                        var thisObj   = $(this);                //当前选项卡对象   
                        var thisClass = thisObj.attr('class');  //当前对象的class值
                        if(thisClass == 'selectedTagCls'){
                            return false;                       //如果当前选项卡已经选中,重复选中无效
                        }
                        //下面将当前选中的选项卡,背景轮换样式:给定选中的class,同胞的其它选项卡移除特定的class
                        thisObj.addClass('selectedTagCls').siblings('h3').removeClass('selectedTagCls');
                        //下面两行对选项卡标题颜色轮换样式
                        thisObj.children('a[class!="itemTitle"]').addClass('itemTitle');
                        thisObj.siblings('h3').children('a[class="itemTitle"]').removeClass('itemTitle'); 
                        //////////////////////////////////////////////////////////////
                        //下面动态载入内容
                        $('#content').stop();
                        $('#content').fadeOut('fast',function(){
                            $('#content').load($('a:eq(0)',thisObj).attr('href')).fadeIn('fast');
                        });                   
                    });        
            });
        </script>
    </head>
    <body>
        <div id="main">
            <div id="tagsBox">
                <h3 class="selectedTagCls"><a href="card.php?cid=1" class="itemTitle">第一项</a></h3>
                <h3><a href="card.php?cid=2">第二项</a></h3>
                <h3><a href="card.php?cid=3">第三项</a></h3>
            </div>
            <div id="contentBox">
                <div id="content"></div>
            </div>
        </div>
    
    </body>
    </html>
  • 相关阅读:
    关于Slowloris HTTP DoS
    [转]更新SDK失败后,出现无法找到SDK location的解决方法
    [吐槽文]一篇课设小结
    无聊时候打打字之百度地图 【更新中】
    git初学 多多指教
    无聊的时候打打字之寒假项目小记录
    机会来了,创业你准备好了吗?
    技术高速发展,IT人员路在何方?
    开发Web应用程序常用优化性能的技巧
    DataTable中存在空值 输出到EXCEL时格式变乱的解决方法【附代码】
  • 原文地址:https://www.cnblogs.com/martinzhang/p/3251789.html
Copyright © 2011-2022 走看看