JS实现自动变换的菜单效果代码
作者:bea
本文实例讲述了JS实现自动变换的菜单效果代码。分享给大家供大家参考。具体如下: 这是一款自动变换的JS菜单,由原来的一款自动TAB修改而成的,有需要的就拿去,代码内有几个JS函数,分别用来控制TAB的自动切换。 运行效果截图如下: 在线演示地址如下: http://demo./js/2015/js-auto-cha-menu-codes/ 具体代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transition
本文实例讲述了JS实现自动变换的菜单效果代码。分享给大家供大家参考。具体如下:
这是一款自动变换的JS菜单,由原来的一款自动TAB修改而成的,有需要的就拿去,代码内有几个JS函数,分别用来控制TAB的自动切换。
运行效果截图如下:
在线演示地址如下:
http://demo./js/2015/js-auto-cha-menu-codes/
具体代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<title>简洁Tab</title>
<style type="text/css">
<!--
body, div, ul, li {padding:0;text-align:center;}
body {font:12px "宋体";text-align:center;}
a:link {color:#00F;text-decoration:none;}
a:visited {color: #00F;text-decoration:none;}
a:hover {color: #c00;text-decoration:underline;}
ul {list-style:none;}
/*选项卡1*/
#Tab1 {width:900px;margin:0px;padding:0px;margin:0 auto;}
/*菜单class*/
.Menubox {width:100%;background:url();height:28px;line-height:28px;}
.Menubox ul {margin:0px;padding:0px;}
.Menubox li {float:left;display:block;cursor:pointer;width:114px;text-align:center;color:#949694;font-weight:bold;}
.Menubox li.hover {padding:0px;background:#fff;width:116px;border-left:1px solid #A8C29F;border-top:1px solid #A8C29F;border-right:1px solid #A8C29F;background:url
();color:#739242;font-weight:bold;height:27px;line-height:27px;}
.Contentbox {clear:both;margin-top:0px;border:1px solid #A8C29F;border-top:none;height:181px;text-align:center;padding-top:8px;}
-->
</style>
</head>
<body>
<br>
<br>
<div id="Tab1">
<div class="Menubox">
<ul>
<li id="one0" onmouseover="setTab('one',0,7)" class="hover">新闻1</li>
<li id="one1" onmouseover="setTab('one',1,7)" >新闻2</li>
<li id="one2" onmouseover="setTab('one',2,7)">新闻3</li>
<li id="one3" onmouseover="setTab('one',3,7)">新闻4</li>
<li id="one4" onmouseover="setTab('one',4,7)">新闻5</li>
<li id="one5" onmouseover="setTab('one',5,7)">新闻6</li>
<li id="one6" onmouseover="setTab('one',6,7)">新闻7</li>
</ul>
</div>
</div>
<br>
<script>
<!--
/*第一种形式 第二种形式 更换显示样式*/
var index;
function setTab(name,cursel,n){
for(var i=0;i<n;i++){
var menu=document.getElementById(name+i);
menu.className=i==cursel?"hover":"";
if (menu.className=="hover")
index=i;
}
}
var num=0;
var AutoPlayObj=null;
function d()
{
setTab('one',num%7,7);
num++;
}
function AutoPlay()
{
clearInterval(AutoPlayObj);
AutoPlayObj=setInterval('d()',1000)
};
AutoPlay();
var tab1 = document.getElementById("Tab1");
tab1.onmouseover = function (){
num=index;
clearInterval(AutoPlayObj);
}
tab1.onmouseout = function(){AutoPlay();}
//-->
</script>
</body>
</html>
希望本文所述对大家的JavaScript程序设计有所帮助。
有用 | 无用
这是一款自动变换的JS菜单,由原来的一款自动TAB修改而成的,有需要的就拿去,代码内有几个JS函数,分别用来控制TAB的自动切换。
运行效果截图如下:
在线演示地址如下:
http://demo./js/2015/js-auto-cha-menu-codes/
具体代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<title>简洁Tab</title>
<style type="text/css">
<!--
body, div, ul, li {padding:0;text-align:center;}
body {font:12px "宋体";text-align:center;}
a:link {color:#00F;text-decoration:none;}
a:visited {color: #00F;text-decoration:none;}
a:hover {color: #c00;text-decoration:underline;}
ul {list-style:none;}
/*选项卡1*/
#Tab1 {width:900px;margin:0px;padding:0px;margin:0 auto;}
/*菜单class*/
.Menubox {width:100%;background:url();height:28px;line-height:28px;}
.Menubox ul {margin:0px;padding:0px;}
.Menubox li {float:left;display:block;cursor:pointer;width:114px;text-align:center;color:#949694;font-weight:bold;}
.Menubox li.hover {padding:0px;background:#fff;width:116px;border-left:1px solid #A8C29F;border-top:1px solid #A8C29F;border-right:1px solid #A8C29F;background:url
();color:#739242;font-weight:bold;height:27px;line-height:27px;}
.Contentbox {clear:both;margin-top:0px;border:1px solid #A8C29F;border-top:none;height:181px;text-align:center;padding-top:8px;}
-->
</style>
</head>
<body>
<br>
<br>
<div id="Tab1">
<div class="Menubox">
<ul>
<li id="one0" onmouseover="setTab('one',0,7)" class="hover">新闻1</li>
<li id="one1" onmouseover="setTab('one',1,7)" >新闻2</li>
<li id="one2" onmouseover="setTab('one',2,7)">新闻3</li>
<li id="one3" onmouseover="setTab('one',3,7)">新闻4</li>
<li id="one4" onmouseover="setTab('one',4,7)">新闻5</li>
<li id="one5" onmouseover="setTab('one',5,7)">新闻6</li>
<li id="one6" onmouseover="setTab('one',6,7)">新闻7</li>
</ul>
</div>
</div>
<br>
<script>
<!--
/*第一种形式 第二种形式 更换显示样式*/
var index;
function setTab(name,cursel,n){
for(var i=0;i<n;i++){
var menu=document.getElementById(name+i);
menu.className=i==cursel?"hover":"";
if (menu.className=="hover")
index=i;
}
}
var num=0;
var AutoPlayObj=null;
function d()
{
setTab('one',num%7,7);
num++;
}
function AutoPlay()
{
clearInterval(AutoPlayObj);
AutoPlayObj=setInterval('d()',1000)
};
AutoPlay();
var tab1 = document.getElementById("Tab1");
tab1.onmouseover = function (){
num=index;
clearInterval(AutoPlayObj);
}
tab1.onmouseout = function(){AutoPlay();}
//-->
</script>
</body>
</html>
希望本文所述对大家的JavaScript程序设计有所帮助。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- jQuery+css实现的蓝色水平二级导航菜单效果代码
- js实现的后台左侧管理菜单代码
- 微信企业号开发之微信考勤Cookies的使用
- 微信企业号开发之微信考勤百度地图定位
- JavaScript处理解析JSON数据过程详解
- 在easyUI开发中,出现jquery.easyui.min.js函数库问题的解决办法
- JavaScript实现算术平方根算法-代码超简单
- js图片卷帘门导航菜单特效代码分享
- jQuery超精致图片轮播幻灯片特效代码分享
- 手机端转盘抽奖代码分享
- JS+CSS实现大气的黑色首页导航菜单效果代码
- 原生JS实现仿淘宝网左侧商品分类菜单效果代码
- JS+CSS实现电子商务网站导航模板效果代码
- 如何解决谷歌浏览器下jquery无法获取图片的尺寸
- js实现的动画导航菜单效果代码
- js实现3D图片逐张轮播幻灯片特效代码分享
- 简单实现兼容各大浏览器的js复制内容到剪切板
- jQuery实现MSN中文网滑动Tab菜单效果代码
- js基于面向对象实现网页TAB选项卡菜单效果代码