实用的Jquery选项卡TAB示例代码

CSS 样式部分:


<style type="text/css"> .order_box .stitle
{ width: 825px; clear: right; height: 27px; border-bottom: 2px solid #A10000; } .order_box .stitle .close { width: 80px; height: 18px; border-top: 1px solid #dedede; border-left: 1px solid #dedede; border-right: 1px solid #dedede; background: #f1f1f1; color: #000; text-align: center; float: left; margin-right: 5px; padding-top: 8px; } .order_box .stitle .open { width: 82px; height: 20px; background: #A10000; color: #fff; text-align: center; float: left; margin-right: 5px; padding-top: 8px; overflow: hidden; } .order_box ul li { cursor: pointer; display: list-item; list-style:none; } </style>
JS部分:


<script src="../script/jquery-1.7.1.min.js"></script> <script type="text/javascript"> //选项卡切换 $(function () { $(".stitle li").click(function () { var index_tab = $(this).parent().children().index($(this)); //选项卡的索引值 $(this).parent().find(".open").removeClass("open").addClass("close"); //选项卡背景处理 $(this).removeClass("close").addClass("open"); var content_obj = $(".cntorder") //内容节点 content_obj.hide(); content_obj.eq(index_tab).show(); }); }); </script>
HTML 部分:


<
body> <div class="order_box"> <div class="stitle"> <ul> <li class="open">选项卡1</li> <li class="close">选项卡2</li> <li class="close">选项卡3</li> </ul> </div> <br /> <br /> <br /> <br /> <br /> <div class="cntorder" >选项卡1选项卡1选项卡1选项卡1选项卡1</div> <div class="cntorder" style="display: none;">选项卡2选项卡2选项卡2选项卡2选项卡2</div> <div class="cntorder" style="display: none;">选项卡3选项卡3选项卡3选项卡3选项卡3</div> </div> </body>

 效果:

常用的jquery总结一下下,当做笔记了,用的时候有地方看看而已

转载于:https://www.cnblogs.com/gxmaspx/p/3341146.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值