JQuery特效,上下移动的选项卡

以下所用的Jquery代码库点击这里下载

<!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>
    <style type="text/css">
        *{ padding:0px; margin:0px;}
        body{ font-size:12px;}
        #accdiorn{ width:400px; height:200px; margin:100px; }
        #accdiorn h3{ font-size:16px; line-height:4px; font-weight:normal;}
    </style>
        <!--uiplus/themes/ui-lightness导入这个路径下的样式文件-->
       <link rel="stylesheet" type="text/css" href="../JQuery/uiplus/themes/ui-lightness/jquery.ui.all.css" />
        <!--导入jquery-1.6.2.min.js--> 
       <script src="../JQuery/jquery-1.6.2.min.js" type="text/javascript"></script>
        <!--以下导入的jquery代码库均是 http://jqueryui.com/download 这里下载的,导入的顺序绝对不能变的--> 
       <script src="../JQuery/uiplus/ui/jquery.ui.core.js" type="text/javascript"></script>
       <script src="../JQuery/uiplus/ui/jquery.ui.widget.js" type="text/javascript"></script>
       <script src="../JQuery/uiplus/ui/jquery.ui.accordion.js" type="text/javascript"></script>
       <script type="text/javascript" language="javascript">
           $(function () {
               $("#accdiorn").accordion(); //调用代码库的这个方法就可以上下移动
           });
       </script>
</head>
<body>
<!--以下这种html格式不可更改-->
    <div id="accdiorn">
        <h3><a href="#">选项1</a></h3>
        <div>
            <p>I am choice 1</p>
            <p>I am choice 1</p>
            <p>I am choice 1</p>
            <p>I am choice 1</p>
        </div>
        <h3><a href="#">选项2</a></h3>
        <div>
            <p>I am choice 2</p>
            <p>I am choice 2</p>
            <p>I am choice 2</p>
            <p>I am choice 2</p>
        </div>
        <h3><a href="#">选项3</a></h3>
        <div>
            <p>I am choice 3</p>
            <p>I am choice 3</p>
            <p>I am choice 3</p>
            <p>I am choice 3</p>
        </div>
    </div>
</body>
</html>

上面是效果图,样式可以自己更改

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
jQuery选项卡特效是一种常用的前端页面交互效果,它通过jQuery库中的一些方法和事件实现。一般来说,选项卡特效会将页面中的不同内容划分到不同的选项卡中,用户可以通过点击不同的选项卡来切换显示不同的内容,从而提高页面的交互性和用户体验。 具体实现方法如下: 1. HTML部分 需要先在HTML中定义好选项卡的外层容器和选项卡导航,以及每个选项卡对应的内容区域。例如: ```html <div class="tab-container"> <ul class="tab-nav"> <li><a href="#tab1">Tab 1</a></li> <li><a href="#tab2">Tab 2</a></li> <li><a href="#tab3">Tab 3</a></li> </ul> <div id="tab1" class="tab-content">This is tab 1 content.</div> <div id="tab2" class="tab-content">This is tab 2 content.</div> <div id="tab3" class="tab-content">This is tab 3 content.</div> </div> ``` 2. CSS部分 需要对选项卡容器、导航和内容进行样式设置,例如: ```css .tab-container { border: 1px solid #ccc; padding: 10px; } .tab-nav { margin: 0; padding: 0; list-style: none; } .tab-nav li { display: inline-block; } .tab-nav a { display: block; padding: 5px 10px; text-decoration: none; border: 1px solid #ccc; border-bottom: none; } .tab-nav a.active { background-color: #fff; } .tab-content { display: none; padding: 10px; } .tab-content.active { display: block; } ``` 3. JavaScript部分 需要使用jQuery库中的一些方法和事件来实现选项卡切换效果,例如: ```javascript $(function() { $('.tab-nav a').click(function() { // 移除当前选中状态 $('.tab-nav a').removeClass('active'); $('.tab-content').removeClass('active'); // 添加新的选中状态 $(this).addClass('active'); $($(this).attr('href')).addClass('active'); return false; }); }); ``` 这样,就可以实现一个简单的jQuery选项卡特效了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值