通过使用ul和div来,借助于jquery来实现选项卡的显示与隐藏

<form action="" method="post">
<div>
<ul>
<li><a >哈哈哈哈</a></li>
</ul>
</div>

<div >
<div class="tab" >

</div>
<!-- End #tab5 -->
</div>
</form>

<script type="text/javascript">
$(document).ready(function (e) {
$('.tab').each(function (e) {
if (e == 0)
$(this).show();//首次加载的时候默认显示第一个
else
$(this).hide();
});
})
//给每一个atab绑定单击事件
$('.atab').bind('click', function () {
$('.tab').hide();//隐藏所有内容
var attr = $(this).attr('id');
var id = '#' + attr.substring(1, attr.length);
$(id).show();//显示当前选中项
});
</script>

相关文章:

  • 2022-02-11
  • 2021-12-28
  • 2022-02-16
  • 2021-08-17
  • 2021-07-28
  • 2021-06-14
  • 2022-12-23
  • 2021-09-18
猜你喜欢
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
相关资源
相似解决方案