我浏览过一些类似的问题 - 但我一直在寻找永远,没有运气发现一个实现,就像我期待做的一样。jQuery .toggle()模式显示/隐藏对话框
这很简单:
<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;
});
})
'$( “接触 ”)的hide();'应该是'$(“。contact_box”)隐藏();'吧? “不起作用”是什么意思?点击什么都不做? – 2011-03-17 01:05:14
你是对的 - 在我正在编写的代码中是正确的 - 只是编辑了问题......哎呀!但是,仍然没有工作。 – Brian 2011-03-17 01:05:54
“不起作用”是什么意思?点击时没有任何反应? – 2011-03-17 01:07:42