程序员的知识教程库

网站首页 > 教程分享 正文

实用的jQuery tab选项卡特效(实用的jquery+tab选项卡特效怎么用)

henian88 2024-08-18 17:05:27 教程分享 6 ℃ 0 评论

实用的jQuery tab选项卡特效,可自由滑动或者点击,代码如下:

<!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=gb2312" />

<title>实用的jQuery tab选项卡特效</title>

<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>

<script type="text/javascript">

$(document).ready(function(){

$('.ct:gt(0)').hide(); /*gt(0) 大于第一个*/

var tab = $('.box ul li');

tab.click(function(){ /*click点击事件和hover悬停事件互换*/

$(this).addClass('one').siblings().removeClass(); /*siblings 他的兄弟*/

var tab_index = tab.index(this);

$('.ct').eq(tab.index(this)).show().siblings().hide();

});

});

</script>

<style type="text/css">

* { padding:0; margin:0;}

body { font-size:12px; padding:100px;}

ul { list-style-type:none;}

.box ul { height:30px; line-height:30px;}

.box ul li { float:left; padding:0 10px; position:relative; cursor:pointer;border:1px solid #000;margin-right:5px; border-bottom:none;border-radius: 4px;}

.content { width:225px; border:1px solid #000; padding:10px; height:100px;}

* html .content { margin-top:-1px;}

.box ul li.one { background:red;}

</style>

</head>

<body>

<div class="box">

<!--菜单部分-->

<ul>

<li class="one">菜单一</li>

<li>菜单二</li>

<li>菜单三</li>

<li>菜单四</li>

</ul>

<!--菜单部分结束-->

<!--内容部分-->

<div class="content">

<div class="ct">内容一</div>

<div class="ct">内容二</div>

<div class="ct">内容三</div>

<div class="ct">内容四</div>

</div>

<!--内容部分结束-->

</div>

</body>

</html>

效果图如下:

除注明外的文章,均为来源:汤久生博客(QQ:1917843637),转载请保留本文地址!

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表