Jquery 实现Tab效果 思路是js思路
作者:bea
代码如下: <!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> <title></title> <scrip
代码如下:
<!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>
<title></title>
<script src="http://img./jslib/jquery/jquery.js" type="text/javascript"></script>
<style type="text/css">
.tab
{
background-color: #FAFAFA;
margin: 5px 8px;
padding: 5px 10px;
}
.tab p span
{
background-color: #EFEFEF;
border: 1px solid #CCCCCC;
cursor: pointer;
margin-right: 6px;
padding: 2px 5px;
}
.tab p span.current
{
background-color: #FAFAFA;
border-bottom-color: #fafafa;
}
.tab p
{
border-bottom: 1px solid #CCCCCC;
font-weight: bold;
padding: 0 10px 2px;
}
.tab li
{
border-bottom: 1px dotted #CCCCCC;
padding-bottom: 3px;
margin: 5px 0;
}
.tab .mhot, .tab.allhot
{
display: none;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$(".tab span:first").addClass("current"); //为第一个SPAN添加当前效果样式
$(".tab ul:not(:first)").hide(); //隐藏其它的UL
$(".tab span").mouseover(function() {
$(".tab span").removeClass("current"); //去掉所有SPAN的样式
$(this).addClass("current");
$(".tab ul").hide();
$("." + $(this).attr("id")).fadeIn('slow');
});
});
</script>
</head>
<body>
<div class="tab">
<p>
<span id="tab1">tab1</span> <span id="tab2">tab2</span> <span id="tab3">tab3</span></p>
<ul class="tab1">
<li></li><li></li><li>我和我</li></ul>
<ul class="tab2">
<li>一花一世办</li><li>一草一天堂</li></ul>
<ul class="tab3">
<li>阿里巴巴</li><li>阿里巴巴</li><li>一草一天堂</li><li>我和我的祖国</li><li>最爱的地方</li></ul>
</div>
</body>
</html>
演示代码
http://demo./js/jquery_tab/index.htm
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- javascript实现的像java、c#之类的sleep暂停的函数代码
- ExtJs之带图片的下拉列表框插件
- JavaScript replace(rgExp,fn)正则替换的用法
- JavaScript isPrototypeOf和hasOwnProperty使用区别
- AppBaseJs 类库 网上常用的javascript函数及其他js类库写的
- JavaScript类和继承 constructor属性
- Js 网页上反复显示隐藏效果的文本
- 爆炸式的JS圆形浮动菜单特效代码
- JS 日历控件(蓝色)
- js 钻石棋网页游戏代码
- JavaScript 拖拽翻页效果代码
- Js 竖直伸缩菜单(百度)
- CSS 网页顶部固定工具栏拖动无闪烁实现代码
- CSS 图片横向排列实现代码
- select下拉选择框美化实现代码(js+css+图片)
- 纯CSS实现的竖向导航菜单
- javascript 图片滑动切换代码
- js 编写规范
- jquery validation插件表单验证的一个例子