[英]After click, reverse animation on jQuery (Show/Hide)
I'm trying to use the: 我正在尝试使用:
$(document).ready(function() {
$('#showmenu1').click(function() {
$('.menu1').slideDown("slow");
});
});
Effect in jQuery to make a div appear when a trigger is clicked, which it does very successfully. 单击触发器时,jQuery中的效果使div出现,这非常成功。 However I want the animation to reverse to make the div disappear, when that same trigger is clicked again. 但是,当再次单击相同的触发器时,我希望动画反转以使div消失。 The effect I want to make is: 我想做的效果是:
$(document).ready(function() {
$('#showmenu1').click(function() {
$('.menu1').slideUp("slow");
});
});
Any help would be greatly appreciated. 任何帮助将不胜感激。
HTML Example: HTML示例:
<section id="showmenu1" style="background-color:#09F; color:#fff">
<h1>Show Div</h1>
</section>
<div class="menu1" style="display: none; background-color:#09F; color:#fff; padding:0; margin:0">
<ul style="padding:0px; margin:0px; position: relative; text-align: center;">
<li>
<h1 style="margin-top:0">Hello Div</h1>
<p style="margin-top:0">Div is shown</p>
</li>
</ul>
</div>
Cheers 干杯
$('#showmenu1').click(function() {
$('.menu1').slideToggle("slow");
});
Demo : http://jsfiddle.net/wL71w8td/ 演示: http : //jsfiddle.net/wL71w8td/
ToggleSimply use slideToggle instead: ToggleSimply改为使用slideToggle:
$(document).ready(function() {
$('#showmenu1').click(function() {
$('.menu1').slideToggle("slow");
});
});
Try this: 尝试这个:
$("div").click(function() {
$(this).hide("slide", {
direction: "down"
}, 1000);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.