用JQ写的一个简单的TAB选项效果,支持两个选项以上,扩展性良好

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<title>无标题文档</title>
<script type="text/javascript">
$(document).ready(
function () {
$(
".tab-nav li").click(function (e) {
if (e.target == this) {
var panels = $(".tab-main div");
var tabs = $(this);
var index = $.inArray(this, $(this).parent().find("li"));
if (panels.eq(index)[0]) {
tabs.removeClass(
"cur").eq(index).addClass("cur");
panels.css(
"display", "none").eq(index).css("display", "block");
}
}

return false;
});
})

</script>
<style type="text/css">
li
{
width
: 200px;
cursor
:pointer
}
</style>
</head>
<body>
<ul class="tab-nav">
<li class="cur">1</li>
<li>2</li>
<li>3</li>
</ul>
<div class="tab-main">
<div style="display:block"> 1 </div>
<div style="display:none"> 2 </div>
<div style="display:none"> 3 </div>
</div>
</body>
</html>

相关文章:

  • 2021-10-03
  • 2021-04-08
  • 2022-12-23
  • 2022-12-23
  • 2022-03-09
  • 2022-12-23
  • 2021-07-11
  • 2022-01-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
相关资源
相似解决方案