联系我们
简单又实用的WordPress网站制作教学
当前位置:网站首页 > 网页前端技术 > 正文

Jquery的Tabs内容轮换效果实现代码,几行搞定 - Web前端

作者:98wpeu发布时间:2026-10-02分类:网页前端技术浏览:14


导读:复制代码代码如下:<!DOCtypehtmlPUBLIC"-//W3C//DTDxhtml1.0Transitional//EN""http://www.w3....
复制代码 代码如下:
<!DOCtypehtml 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>JQuery的tabs内容轮换效果实现代码,几行搞定</title> 
<script language="javascript" type="text/JavaScript" src="/Scripts/jQuery-1.4.4.min.JS"></script> 
  <style type="text/CSS"> 
        * { margin:0; padding:0;} 
        body { font:12px Verdana, Geneva, sans-serif; color:#404040;}    
        .TABs { margin:10px 0 0 20px; width:360px; position:relative; overflow:hidden; height:1%; height:160px;} 
        .tabs span { z-index:2; font-size:12px; border:1px solid #d5d5d5; width:95px; height:25px; line-height:25px; text-align:center; float:left; margin-right:5px; cursor:pointer;} 
        span.active { background-position:0 -25px; background-color:#d5d5d5;} 
        #tab-01, #tab-02, #tab-03 { position:absolute; top:26px; left:0; width:338px; padding:10px; height:93px; border:1px solid #d5d5d5; z-index:1;} 
        #tab-02, #tab-03 { display:none;} 
    </style> 
    <script type="text/Javascript"> 
        $(document).ready(function () { 
            $('.tabs span').mouSEOver(function () { 
              //div隐藏
              $('.tabs div').hide();
              //查找.tabs span同辈元素span 后面紧邻的同辈元素div显示
              $(this).siblings('span').removeclass('active').end().addClass('active').next('div').show(); 
            }); 
        }); 
    </script> 
</head> 

<body> 
    <div class="tabs"> 
        <!-- 默认第一个tab为激活状态 --> 
        <span class="active">热点新闻</span> 
        <div id="tab-01">news</div> 
        <span>娱乐新闻</span> 
        <div id="tab-02">enteriment</div> 
        <span>就业形势</span> 
        <div id="tab-03">jobs</div> 
    </div> 
</body> 
</html> 

标签:几行效果代码内容WebTabs


网页前端技术排行
最近发表
网站分类
标签列表