我浏览了一些类似的问题 - 但是我一直在寻找一个与我想要做的相同的实现,可惜一直没有找到。
这非常简单:
<a class="contacttoggle" href="#">Contact</a>
<div>Lots of content between</div>
<div>Lots of content between</div>
<div>Lots of content between</div>
<div>Lots of content between</div>
<div class="contact_box">Contact info that is initially hidden and then fades in when the "contact_toggle" Contact link above is clicked</div>
我希望这个元素能够淡入,并且在页面上绝对定位(不用担心,CSS我可以处理)。我绝对不想有滑动效果,只需要淡入即可。
我感觉这段代码应该可以工作,但是它没有 :(
$(document).ready(function(){
/* function to show and hide main navigation conatct box */
$(".contact_box").hide();
$('a.contacttoggle').click(function() {
$(this).next("div").find(".contact_box").toggle(400);
return false;
});
})
$(".contact").hide();
应该改为$(".contact_box").hide();
,对吧?“不起作用”是什么意思?点击没有反应吗? - jon_darkstar