Tab中的嵌套选项卡

时间:2015-09-17 00:46:59

标签: javascript jquery

我遇到嵌套标签的问题。

如果单击第一个选项卡(ul.plaene li a)我想要的是加载嵌套选项卡的第一个内容。

html代码通常是一个PHP循环,我不想改变顺序。

我找不到解决这个问题的方法。

The output is: 

iMac-de-:Desktop be$ gcc programa3.c
iMac-de-:Desktop be$ ./a.out
1: el id del proceso main es 4466
2: el id del proceso hijo es 4467
padre: 0
padre: 1
padre: 2
padre: 3
padre: 4
padre: 5
padre: 6
padre: 7
padre: 8
padre: 9
padre: 10
2: el id del proceso hijo es 0
hijo 1: 10
hijo 1: 9
hijo 1: 8
hijo 1: 7
hijo 1: 6
hijo 1: 5
hijo 1: 4
hijo 1: 3
hijo 1: 2
hijo 1: 1
hijo 1: 0
getppid() hijo 1=1
iMac-de-Bertha:Desktop berhtvega$ hijo 2: 10
hijo 2: 9
hijo 2: 8
hijo 2: 7
hijo 2: 6
hijo 2: 5
hijo 2: 4
hijo 2: 3
hijo 2: 2
hijo 2: 1
hijo 2: 0
getppid() hijo 2=1
$(".stock li:first").addClass("current");
$(".tab-inhalt:first").fadeIn();
$(".tab-content:first").fadeIn();

$(".plaene a").click(function(event) {
  event.preventDefault();
  $(this).parent().addClass("current");
  $(this).parent().siblings().removeClass("current");
  var tab = $(this).attr("href");
  $(".tab-content").not(tab).css("display", "none");
  $(tab).fadeIn();
});

$(".reiter a").click(function(event) {
  event.preventDefault();
  $(this).parent().addClass("current");
  $(this).parent().siblings().removeClass("current");
  var tab = $(this).attr("href");
  $(".tab-inhalt").not(tab).css("display", "none");
  $(tab).fadeIn();
});
.tab-content,
.tab-inhalt {
  display: none;
}
.stock li {
  text-decoration: none;
  list-style: none;
  display: inline-block;
  margin: 0 20px 0 0;
}
.stock a {
  color: #0094cd;
  text-decoration: none;
  list-style: none;
}
.stock li.current a {
  color: #4c565c;
}
.plaene a.current {
  color: #4c565c;
}
.tab-alles {
  width: 100%;
  background-color: #f1f2f4;
  margin-top: 15px;
}
.tab-oben li {
  text-decoration: none;
  list-style: none;
  display: inline-block;
  margin: 0;
  background-color: #f1f2f4;
}
.tab-oben a {
  color: #0094cd;
  text-decoration: none;
  list-style: none;
  padding: 14px 20px;
  display: block;
}

1 个答案:

答案 0 :(得分:0)

您需要在$("li:first a",tab).click()函数的末尾添加$(".plaene a").click()

$(".plaene a").click(function(event) {
  event.preventDefault();
  $(this).parent().addClass("current");
  $(this).parent().siblings().removeClass("current");
  var tab = $(this).attr("href");
  $(".tab-content").not(tab).css("display", "none");
  $(tab).fadeIn();
  $("li:first a",tab).click();
});

这是一个有效的JSFiddle

相关问题