JQuery simple implementation of web options carter effect

  • 2020-03-30 04:24:00
  • OfStack

CSS :


        .clear{clear:both; height:0px; overflow:hidden;}
        .tab{width:400px; font-size:12px;}
        .tab_menu ul{padding:0px;margin:0px;}
        .tab_menu li{list-style:none; display:block; float:left;
            background:#C2CEFE; height:22px; line-height:22px;
            padding: 0px 8px; margin-right:6px; border:#86B4CA 1px solid;
        }
        .box{width:400px; height:200px; overflow:hidden; border:#A8C9D9 1px solid; padding:10px 8px; }
        .tab_menu ul li.selected{background:#dadada; cursor:pointer; }
        .hide{display:none;}

jQuery :


        $(function() {
            var $menu_li = $("div.tab_menu ul li");  //Select the web page TAB
            $menu_li.click(function(){
                $(this).addClass("selected") //The current <Li> Highlight < br / >                         .siblings().removeClass("selected"); //Remove other peers <Li>
                var index = $menu_li.index( $(this) ); //Find <Li> Index of child node
                $("div.tab_box > div").eq(index).show() //DIV with index N is displayed
                        .siblings().hide();            //The other tabs hide
            })
        }) 

html :


Related articles: