我一直在关注Youtube贡献者“learnnerd”的教程。 Url here 我使用他提供的代码制作了我的网站。 Here's my website。 (检查服务)
我想在我的主页上链接一个标签,在我的服务页面中打开一个特定的手风琴。我已经研究过,但仍然知之甚少。我对Javascript了解不多。 我的php / html代码如下:
<h2 class="accordion"><a href="#1"> Antenna</a></h2>
<h2 class="accordion"><a href="#2"> Digital</a></h2>
我的脚本(来自“learnnerd(Youtube)”和Atomix(这里))看起来像这样:
$(function(){
$('.accContainer').hide(); //hide all content
$('.accordion').click(function(){
if( $(this).next().is(':hidden') ) {
$('.accordion').next().slideUp();
//triggers the hiding of contents
$(this).next().slideDown();
//triggers slide down of contents
}
return false; //prevents brower default
});
$(".accordion").accordion({
header: "h2", navigation: true
});
}); //document.ready function
谢谢。