【发布时间】:2016-08-11 08:30:01
【问题描述】:
首先:对不起我的英语不好!
例如有两个不同锚点的链接:
<a href="www.test.ch?name=example#anchor1">
<a href="www.test.ch?name=example#anchor2">
当有人点击这些链接之一时,他会自动被站点和位置所吸引,他应该是。很好。
但是在站点中有一个手风琴并且没有显示文本。通过单击带有锚点 2 的链接,应打开带有锚点 2 的位置。
这是 jquery:
<script>
$().ready(function() {
$(".accordeon .ancor").click(function() {
var textContainer = $(this).parent().children(".text");
if (textContainer.is(":visible")) {
textContainer.slideUp();
$(this).attr("src", "images/accordon_open.jpg");
}
else {
textContainer.slideDown();
$(this).attr("src", "images/accordon_close.jpg");
}
});
$(".accordeon .text").hide();
});
</script>
以及链接内容的html:
<div class="accordeon">
<img class="ancor button" src="images/accordon_open.jpg">
<div class="title ancor">
Titel anchor 1
</div>
<div class="text">
<a name="anchor1"></a>
text anchor1 (should be not visible)
</div>
</div>
<div class="accordeon">
<img class="ancor button" src="images/accordon_open.jpg">
<div class="title ancor">
Titel anchor 2
</div>
<div class="text">
<a name="anchor2"></a>
text anchor2 (should be visible, because someone had click the link for it)
</div>
</div>
如何通过单击链接/锚点打开手风琴。感谢您的帮助!
【问题讨论】:
标签: jquery hyperlink anchor accordion