欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery實現(xiàn)簡單的tab標(biāo)簽頁效果

 更新時間:2016年09月12日 15:20:59   作者:onestopweb  
這篇文章主要介紹了jQuery實現(xiàn)簡單的tab標(biāo)簽頁效果,涉及jQuery簡單元素遍歷與樣式動態(tài)操作相關(guān)技巧,需要的朋友可以參考下

本文實例講述了jQuery實現(xiàn)簡單的tab標(biāo)簽頁效果。分享給大家供大家參考,具體如下:

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>tab1</title>
<style type="text/css">
*{ padding: 0; margin: 0;}
li{ list-style-type: none;}
body{ margin: 50px;}
.hide{ display: none;}
.tabTitle ul{ overflow: hidden; _height:1px;}
.tabTitle ul li{ float: left; border: 1px solid #abcdef; border-bottom: none; height: 30px; line-height: 30px; padding: 0 15px; margin-right: 3px; cursor:pointer;}
.current{ background: #abcdef; color:#fff;}
.tabContent div{ border: 1px solid #f60; width: 300px; height: 250px; padding: 15px;}
</style>
</head>
<body>
<!-- 這里是標(biāo)簽標(biāo)題 -->
<div class="tabTitle">
  <ul>
    <li class="current">xhtml</li>
    <li>css</li>
    <li>jquery</li>
  </ul>
</div>
<div class="tabContent">
  <div>xhtml的內(nèi)容</div>
  <div class="hide">css的內(nèi)容</div>
  <div class="hide">jquery的內(nèi)容</div>
</div>
<script src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function(){
  var ali = $('.tabTitle ul li');
  var aDiv = $('.tabContent div');
  var timeId = null;
  ali.mouseover(function(){
    var _this = $(this);
    //setTimeout();的作用是延遲某一段代碼的執(zhí)行
    timeId = setTimeout(function(){
      //$(this)方法屬于哪個元素,$(this)就是指哪個元素
      _this.addClass('current').siblings().removeClass('current');
      //如果想用一組元素控制另一組元素的顯示或者隱藏,需要用到索引
      var index = _this.index();
      aDiv.eq(index).show().siblings().hide();
    },300);
  }).mouseout(function(){
    //clearTimeout的作用是清除定時器
    clearTimeout(timeId);
  });
});
</script>
</body>
</html>

運行效果圖如下:

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery切換特效與技巧總結(jié)》、《jQuery擴展技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jquery中Ajax用法總結(jié)》、《jQuery常見經(jīng)典特效匯總》、《jQuery動畫與特效用法總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對大家jQuery程序設(shè)計有所幫助。

相關(guān)文章

最新評論