Jquery之选项卡效果

来源:互联网 发布:7.0wow mac 插件 编辑:程序博客网 时间:2024/06/05 17:03
<!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=utf-8" />
<title>Jquery之选项卡效果</title>

<style type="text/css">
    *{padding:0px; margin:0px; list-style:none; text-decoration: none; text-align: center; vertical-align:middle;}
    .tab{ border: 1px solid black; width:350px; height: 350px; position: relative; left: 200px; top:100px;}
    .tab_ul{  width: 300px; height: 30px; line-height:30px;}
    .tab_ul li{ width: 98px;height: 98%; float:left; border: 1px solid black;}
    .tab_div{ background: #9CF; overflow: hidden; clear:both; width: 300px; height: 100px;}
    .tab_div div{ float:left; width: 300px; height: 100px;}
    .head{ background: #FF0;}
    .red{ background: red;}
    .orange{ background: orange;}
    .blue{ background: blue;}
</style>
<script type="text/javascript" src="jquery-3.2.1.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(e) {    
     $(".tab_div").find("div").eq(0).show().siblings().hide();
    $(".tab_ul").find("li").eq(0).addClass("head");
    $(".tab_ul li").mouseover(
        function(){
            $(this).addClass("head").siblings().removeClass("head").end().parent().next().children("div").eq($(this).index()).show().siblings().hide();
    });

  });
</script>
</head>

<body>
  <div class="tab">
      <ul class="tab_ul">
         <li>红</li>
         <li>黄</li>
         <li>蓝</li>       
      </ul>
      <div class="tab_div">
          <div class="red"></div>
        <div class="orange"></div>
        <div class="blue"></div>
      </div>
  </div>    
</body>

</html>

原创粉丝点击