首页 > Web开发 > 详细

jQuery简单Tab选项卡制作

时间:2014-04-13 18:39:54      阅读:673      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>tab选项卡</title>
<script src="jquery.js"></script>
<script>
$(function(){
    var ali = $(.tabTitle ul li);
    var aDiv = $(.tabContent div);
    var timeId = null;
    ali.mouseover(function() {
        //setTimeout()的作用是延迟某一段代码的执行
        var _this = $(this);
        timeId = setTimeout(function(){
            var index = _this.index();
            _this.addClass(current).siblings().removeClass(current);
            aDiv.eq(index).show().siblings().hide();
        },300);
    }).mouseout(function(){
        //clearTimeout的作用是清除定时器
        clearTimeout(timeId);
    });
});
</script>
<style>
*{padding:0;margin:0;}
body{margin:50px;}
li{list-style: none;}
.tabTitle ul{overflow: hidden;_height:1px;}
.tabTitle ul li{float:left; border:1px solid #abcdef; height: 30px; line-height: 30px; padding:0 15px; margin-right:3px; cursor:pointer;}
.tabContent div{border:1px solid #f60; width: 300px; height: 100px; padding:10px;}
.hide{display: none;}
.current{background: #abcdef; color: #fff;}
</style>
</head>
<body>
    <!-- 这里是标签标题 -->
    <div class="tabTitle">
        <ul>
            <li class="current">xhtml</li>
            <li>css</li>
            <li>jquery</li>
        </ul>
    </div>
    <!-- 这里是内容 -->
    <div class="tabContent">
        <div>xhtml的内容</div>
        <div class="hide">css的内容</div>
        <div class="hide">jQuery的内容</div>
    </div>
</body>
</html>
bubuko.com,布布扣

 

jQuery简单Tab选项卡制作,布布扣,bubuko.com

jQuery简单Tab选项卡制作

原文:http://www.cnblogs.com/littlefly/p/3662402.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!