【发布时间】:2014-07-14 18:43:38
【问题描述】:
我已经搜索并找到了这段代码,所以我想这是我应该使用的开始,但我真的不知道什么属性是错误的。
<script type="text/javascript">
$("a").click(function (){
$(".EventShowID").hide();
$("#" + $(this).attr("class")).show().siblings('EventShowID').hide();
});
</script>
链接 HTML:
<a href="#EventID1" class="EventID1">EVENT!</a>
<a href="#EventID3" class="EventID3">EVENT!</a>
<a href="#EventID4" class="EventID4">EVENT!</a>
分区:
<div id="EventShow">
<div id="EventID1" class="EventShowID">Test Event #1<br>Testing adding an event for fun.</div>
<div id="EventID3" class="EventShowID">Test Event #2<br>Testing adding another event for fun.</div>
<div id="EventID4" class="EventShowID">Test Event #3<br>Testing adding anotheranother event for fun.</div>
</div>
怎么了。 :(
【问题讨论】:
-
你试过
.siblings('.EventShowID')吗?虽然你已经在上一行隐藏了它们,所以我不知道你为什么需要再次隐藏它们 -
似乎在工作jsfiddle.net/BpYKn
-
我想显示与我单击的链接相关的 DIV,并隐藏其余部分。 .siblings('.EventShowID') 没有任何区别:(
-
你的 jQuery 链接是否正确?...
标签: javascript jquery html css hyperlink