最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js基于面向?qū)ο髮崿F(xiàn)網(wǎng)頁TAB選項卡菜單效果代碼

 更新時間:2015年09月09日 12:15:47   作者:企鵝  
這篇文章主要介紹了js基于面向?qū)ο髮崿F(xiàn)網(wǎng)頁TAB選項卡菜單效果代碼,實例演示了鼠標(biāo)滑過即點擊兩種方式實現(xiàn)tab選項卡切換功能,涉及JavaScript鼠標(biāo)事件控制頁面元素屬性變換的功能,需要的朋友可以參考下

本文實例講述了js基于面向?qū)ο髮崿F(xiàn)網(wǎng)頁TAB選項卡菜單效果代碼。分享給大家供大家參考。具體如下:

這是一款自動的網(wǎng)頁TAB,基于面向?qū)ο蟮倪x項卡菜單,由于時間關(guān)系只做了簡單的實現(xiàn),界面沒有美化,不多做介紹了。

先來看看運行效果截圖:

在線演示地址如下:

http://demo.jb51.net/js/2015/js-mxdx-tab-cha-style-codes/

具體代碼如下:

<!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>選項卡</title>
<style type="text/css">
body, h2, p {
 margin:0px;
 padding:0px;
}
ul, li {
 margin:0px;
 padding:0px;
 float:left;
 list-style-type:none;
}
body {
 font-size:12px;
}
.box {
 width:722px;
 height:99px;
 margin:10px auto;
 border:1px solid #dedede;
}
.list {
 width:711px;
 height:22px;
 float:left;
 padding:4px 0 0 9px;
 border-top:1px solid #fff;
 border-left:1px solid #fff;
 border-right:1px solid #fff;
 background:url(images/tabbg.jpg) repeat-x;
}
.list li {
 width:74px;
 height:22px;
 float:left;
 cursor:pointer;
 color:#656565;
 line-height:22px;
 text-align:center;
}
.list li.hove {
 width:72px;
 height:20px;
 color:#fc6703;
 line-height:20px;
 border-top:1px solid #dedede;
 border-left:1px solid #dedede;
 border-right:1px solid #dedede;
 border-bottom:1px solid #fff;
 background:#fff;
}
.content {
 width:722px;
 height:72px;
 float:left;
 display:none;
}
</style>
<script type="text/javascript">
function $(id){
 return typeof id === "string" ? document.getElementById(id) : id;
}
function $$(oParent, elem){
 return (oParent || document).getElementsByTagName(elem);
}
function $$$(oParent, sClass){
 var aElem = $$(oParent, '*');
 var aClass = [];
 var i = 0;
 for(i=0;i<aElem.length;i++)if(aElem[i].className == sClass)aClass.push(aElem[i]);
 return aClass;
}
function addEvent(oElm, strEvent, fuc) {
 window.addEventListener ? oElm.addEventListener(strEvent, fuc, false) : oElm.attachEvent('on' + strEvent, fuc);
};
function Tab(){
 this.initialize.apply(this, arguments);
}
Object.extend = function(destination, source) {
 for (var property in source) {
 destination[property] = source[property];
 }
 return destination;
};
Tab.prototype = {
 initialize : function(obj, dis, content, onEnd, eq){
  this.obj = $(obj);
  this.oList = $$$(this.obj, 'list')[0];
  this.aCont = $$$(this.obj, content);
  this.oUl = $$(this.oList, 'ul')[0];
  this.aLi = this.oUl.children;
  this.timer = null;
  eq ? (this.aLi.length < eq ? eq = 0 : eq) : eq = 0;
  this.oEve(onEnd);
  this.onEnd.method == 'mouseover' ? this.method = "mouseover" : this.method = "click";
  this.onEnd.autoplay == 'stop' ? this.autoplay = "stop" : this.autoplay = "play";
  this.aCont[eq].style.display = 'block';
  this.aLi[eq].className = 'hove';
  this.display(dis);
  this.autoPlayTab(eq, dis);
 },
 oEve: function(onEnd){
 this.onEnd = {
  method: 'mouseover',
   autoplay: 'stop',
 };
 Object.extend(this.onEnd, onEnd || {});
 },
 display : function(dis){
  var _this = this;
  var i = iNow = 0;
  for(i=0;i<this.aLi.length;i++){
   (function(){
    var j = i;
    addEvent(_this.aLi[j], _this.method,
    function() {
     _this.fnClick(j,dis);
     _this.autoPlayTab(j, dis);
    })
    })()
  }
 },
 autoPlayTab : function(iNow, dis){
  if(this.autoplay == 'play'){
   var _this = this;
   this.iNow = iNow;
   this.obj.onmouseover = function(){
    clearInterval(_this.timer);
   };
   this.obj.onmouseout = function(){
    clearInterval(_this.timer);
    _this.timer = setInterval(playTab,5000);
   };
   clearInterval(_this.timer);
   _this.timer = setInterval(playTab,5000);
   function playTab(){
    if(_this.iNow == _this.aLi.length)_this.iNow = 0;
    _this.fnClick(_this.iNow, dis)
    _this.iNow++
   }
  }
 },
 fnClick : function(oBtn, dis){
  var i = 0;
  for(i=0;i<this.aLi.length;i++)this.aLi[i].className = '',this.aCont[i].style.display = 'none';
  this.aLi[oBtn].className = dis;
  this.aCont[oBtn].style.display = 'block';
 }
};
window.onload = function(){
 new Tab("box", 'hove', 'content', {
 method : 'mouseover',
  autoplay : 'play'
 },0);
 new Tab("box1", 'hove', 'content', {
 method : 'click',
 },0);
};
</script>
</head>
<body>
<div id="box" class="box">
 <div class="list">
  <ul>
  <li>團購導(dǎo)航</li>
  <li>商城導(dǎo)航</li>
  <li>淘寶導(dǎo)航</li>
 </ul>
 </div>
 <div class="content">111</div>
 <div class="content">222</div>
 <div class="content">333</div>
</div>
<div id="box1" class="box">
 <div class="list">
  <ul>
  <li>團購導(dǎo)航</li>
  <li>商城導(dǎo)航</li>
  <li>淘寶導(dǎo)航</li>
 </ul>
 </div>
 <div class="content">111</div>
 <div class="content">222</div>
 <div class="content">333</div>
</div>
</body>
</html>

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

相關(guān)文章

  • 理解JavaScript中的對象

    理解JavaScript中的對象

    這篇文章主要介紹了如何理解JavaScript中的對象,幫助大家更好的學(xué)習(xí)JavaScript,感興趣的朋友可以了解下
    2020-08-08
  • jscript之Open an Excel Spreadsheet

    jscript之Open an Excel Spreadsheet

    jscript之Open an Excel Spreadsheet...
    2007-06-06
  • js獲取當(dāng)前日期前七天的方法

    js獲取當(dāng)前日期前七天的方法

    這篇文章主要介紹了js獲取當(dāng)前日期前七天的方法,涉及javascript中for語句及日期操作的技巧,需要的朋友可以參考下
    2015-02-02
  • IE6兼容透明背景圖片及解決方案

    IE6兼容透明背景圖片及解決方案

    這篇文章給大家介紹IE6兼容透明背景圖片以及在IE6中的透明圖片不是透明顯示的解決方案,有需要的朋友可以參考下
    2015-08-08
  • document.addEventListener使用介紹

    document.addEventListener使用介紹

    這篇文章主要介紹了document.addEventListener,下面有個示例,大家可以參考下
    2014-03-03
  • 細(xì)品javascript 尋址,閉包,對象模型和相關(guān)問題

    細(xì)品javascript 尋址,閉包,對象模型和相關(guān)問題

    似乎某些程序員的集合是不相交的,就好像JS程序員和玩編譯原理和CPU指令的匯編程序員就幾乎沒有交叉。前些日子討論的火熱的“作用域鏈”問題,說白了就是尋址問題,不過,這個在C中十分簡單的問題卻被JS這個動態(tài)語言弄得很復(fù)雜。
    2009-04-04
  • js查錯流程歸納

    js查錯流程歸納

    歸納是為了更好的理解。平時同事有問題找我?guī)兔鉀Q問題,往往都是很小的問題,這種情況他們并不是缺乏解決問題的知識,而是需要找到問題的辦法
    2012-05-05
  • JavaScript 作用域鏈解析

    JavaScript 作用域鏈解析

    一直對Js的作用域有點迷糊,今天偶然讀到Javascript權(quán)威指南,立馬被吸引住了,寫的真不錯。我看的是第六版本,相當(dāng)?shù)暮瘢蟾?000多頁,Js博大精深,要熟悉精通需要大毅力大功夫。謝謝心得吧
    2014-11-11
  • JavaScript實現(xiàn)的一個日期格式化函數(shù)分享

    JavaScript實現(xiàn)的一個日期格式化函數(shù)分享

    這篇文章主要介紹了JavaScript實現(xiàn)的一個日期格式化函數(shù)分享,本文給出了實現(xiàn)代碼和使用例子,需要的朋友可以參考下
    2014-12-12
  • 前端JavaScript數(shù)組方法總結(jié)(非常詳細(xì)!)

    前端JavaScript數(shù)組方法總結(jié)(非常詳細(xì)!)

    這篇文章主要介紹了JavaScript中數(shù)組對象的常用方法,包括數(shù)組的基本操作、查找、過濾、排序、遍歷等方法,并提供了每個方法的語法和示例,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2025-04-04

最新評論

大石桥市| 镇赉县| 上饶市| 马关县| 南丰县| 中牟县| 铁岭县| 辽阳市| 南开区| 东台市| 彩票| 乃东县| 尼勒克县| 女性| 石阡县| 兰考县| 科技| 万州区| 诸暨市| 镇雄县| 微山县| 临泽县| 勐海县| 菏泽市| 隆德县| 始兴县| 徐水县| 会昌县| 保山市| 磐石市| 湘乡市| 九龙坡区| 昌黎县| 安庆市| 宁陵县| 曲靖市| 乌拉特后旗| 景洪市| 黄骅市| 澎湖县| 绥芬河市|