我已经创建了一个具有锚链接的手风琴,我的问题是,当选择锚链接时,如何触发javascript打开活动的手风琴面板。
<script>
$(function() {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') ==
this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1)
+']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
</script>
<div class="Test">
<a href="#Link 1st">A</a>
</div>
<button class="accordion"><strong><a id="Link 1st"></a>Link 1st</strong>
</button>
<div class="panel"><br />
<H4>Link 1</H4>
</div>