Easy Tab,Based JQuery Core

秦英发
2023-12-01

[code=HTML]
<!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>
        <base target="_blank" />
        <meta name="Keywords" content="<!--投资陕西,凤凰-->,#Keywords" />
        <meta name="Description" content="#page_Description" />
        <title>#title -- #I</title>
        <!--
        <link type="text/css" href="" rel="stylesheet" />
        -->

        <script type="text/javascript" src="jquery-1.3.2.min.js"></script>

        <style type="text/css">
            body{
                margin:0;
                padding:0;
                font-size:14px;
                font-family:Arial,宋体;
                margin:0px auto;
            }
            p{
                text-indent:2em;
                text-align:left;
                margin:0px;
                padding:10px;
                line-height:22px;
            }
            a{
                font-size:14px;
                color:#000;
                text-decoration:none;
            }
            a:hover{
                color:#F00;
            }
            ul{
                margin:0px;
                padding:0px;
                line-height:22px;
            }
            table{
                width:100%;
            }
            td{
                text-align:left;   
            }
        </style>
        <style type="text/css">
            .tab{
                width:600px;
                overflow:hidden;
                background:#FFFFFF;
            }
            .tabItems{
                height:40px;
                position:relative;
            }
            .tabItems ul{
                height:40px;
                background-color:#000;
                margin:0px;
                list-style-type:none;
                overflow:hidden;
            }
            .tabItem{
                margin:0px 5px;
                padding:0px 5px;
                float:left;
                height:px;
                line-height:40px;
                color:#fff;
                background:#000;
                cursor:pointer;
            }
            .tabItem_hover{
                background-color:#FFF;
                color:#000;
                border-top:solid 5px #000;
            }
            .tabContainer{
                background-color:#eeeeee;
                height:300px;
                clear:left;
            }
            .tabContent{
                width:100%;
                height:100%;
                overflow:hidden;
                display:none;
            }

        </style>
        <script type="text/javascript">
            <!-- _________________________________inittab________________________________________ -->
            function initTab(id){
                var tab = document.getElementById(id);
                $(".tabItem",tab).each(function(i){
                    var lazyClick = null;
                    var t = $(this);
                    t.bind("click",function(){
                        var index = $(".tabItem",tab).index(this);
                        if(!$(".tabContent",tab).get(index)){
                            return false;
                        }
                        $(".tabItem",tab).each(function(j){
                            var htc= $($(".tabContent",tab).get(j));
                            var ht = $(this);
                            if(j!=i){
                                ht.removeClass("tabItem_hover");
                                htc.hide();
                            }else{
                                ht.addClass("tabItem_hover");
                                htc.show();
                            }
                        })
                    }).bind("mouseover",function(){
                        lazyClick = setTimeout(function(){
                            t.trigger("click");
                        },1000);
                    }).bind("mouseout",function(){
                        clearTimeout(lazyClick);
                    });;
                });
            }
            <!-- _____________________________onReady ________________________________________ -->
            $(function(){
                initTab("tab1");
            });
        </script>
    </head>
    <body>
        <div id="tab1" class="tab">
            <div class="tabItems">
               
                <ul>
                    <li class="tabItem">页面一</li>
                    <li class="tabItem">页面二</li>
                    <li class="tabItem">页面三</li>
                    <li class="tabItem">页面五</li>
                    <li class="tabItem">页面五</li>
                    <li class="tabItem">页面六</li>
                    <li class="tabItem">页面七</li>
                    <li class="tabItem">页面八</li>
                    <li class="tabItem">页面九</li>
                    <li class="tabItem">页面十</li>
                </ul>
               
            </div>
            <div class="tabContainer">
                <script type="text/javascript">
                    for(var i=0;i<10;i++){
                        document.write("<div class=/"tabContent/"><p>"+i+"</p></div>");
                    }
                </script>
            </div>
        </div>
    </body>
</html>

[/code]

 类似资料:

相关阅读

相关文章

相关问答