Skip to content

Instantly share code, notes, and snippets.

@maninthemirror
Last active February 20, 2016 10:17
Show Gist options
  • Select an option

  • Save maninthemirror/a47e9fce7e59c4145c41 to your computer and use it in GitHub Desktop.

Select an option

Save maninthemirror/a47e9fce7e59c4145c41 to your computer and use it in GitHub Desktop.
jQueryTab
<!-- tab切換 -->
<div class="tabZone">
<!-- 點數 -->
<ul class="tabUl tabAreaFunc">
<li class="tabActive">獲得明細</li>
<li class="taboff">使用明細</li>
</ul>
<!-- end點數-->
<!-- 內容區域-->
<div class="tabArea contentPaddingLR" id="tabArea0">
<table class="twoli">
<tbody>
<tr>
<th>折抵商品</th>
<th>折抵金額</th>
<th>時間</th>
<th>狀態</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="tabArea" id="tabArea1">2222</div>
<!-- end內容區域-->
</div>
<!-- end tab切換 -->
.tabUl {
margin-top: 30px;
padding-left: 30px;
padding-right: 10px;
box-sizing: border-box;
border-bottom: 1px solid #bfbfbf;
}
.tabUl:after {
content: "";
display: table;
clear: both;
}
.tabUl li {
border-right: 1px solid;
border-color: #bfbfbf;
padding: 30px 50px;
float: left;
margin-bottom: -1px;
}
.tabUl li:first-child {
border-left: 1px solid #bfbfbf;
}
.tabUl .tabActive {
border-top: 6px solid #fdb365;
background-color: white;
border-bottom: 1px solid white;
}
.tabUl .taboff {
border-top: 6px solid white;
background-color: #898989;
color: white;
}
.tabArea {
border: 1px solid #bfbfbf;
border-top: 1px solid white;
}
#tabArea1 {
display: none;
}
$("body").on('click', '.tabAreaFunc li', function(event) {
event.preventDefault();
var num = $(this).index(),
$tabArea = $(".tabArea"),
$tabAreaID = $tabArea.attr("id").charAt(7),
$tabAreaShowed = $("#tabArea"+num);
console.log($(this).index());
$tabAreaShowed.fadeIn();
$(".tabArea").not($tabAreaShowed).css('display', 'none');
$(this).removeClass().addClass('tabActive');
$(".tabAreaFunc li").not($(this)).removeClass().addClass('taboff');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment