具有绑定事件时的 SlideUp 或动画
在下面的示例中,我很好奇如何仍然可以使用向上滑动和向下滑动来为 ul 的出现设置动画。我的困惑是,slideUp/slideDown 不显示,在这个例子中,你似乎使用了另一个 css 属性,可见性。在函数 jsddm_open 上,我希望 UL 滑入和滑出。感谢您抽出时间。
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;
function jsddm_open()
{ jsddm_canceltimer();
jsddm_close();
dmenuitem = $(this).find('ul').css('visibility', 'visible');
}
function jsddm_close()
{ if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}
function jsddm_timer()
{ closetimer = window.setTimeout(jsddm_close, timeout);}
function jsddm_canceltimer()
{ if(closetimer)
{ window.clearTimeout(closetimer);
closetimer = null;}}
$(document).ready(function(){
$('#menudropdown > li').bind('mouseover', jsddm_open)
$('#menudropdown > li').bind('mouseout', jsddm_timer)
});
document.onclick = jsddm_close;
In the below example, I am curious how i could still use slide up and slidedown to animate the ul for appearing. My confusion is meant by, slideUp/slideDown are display none, and it seems like in this example thy are using another css property, visibility. On the function jsddm_open, i would like for the UL to slide in and slide out. Thanks for your time.
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;
function jsddm_open()
{ jsddm_canceltimer();
jsddm_close();
dmenuitem = $(this).find('ul').css('visibility', 'visible');
}
function jsddm_close()
{ if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}
function jsddm_timer()
{ closetimer = window.setTimeout(jsddm_close, timeout);}
function jsddm_canceltimer()
{ if(closetimer)
{ window.clearTimeout(closetimer);
closetimer = null;}}
$(document).ready(function(){
$('#menudropdown > li').bind('mouseover', jsddm_open)
$('#menudropdown > li').bind('mouseout', jsddm_timer)
});
document.onclick = jsddm_close;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 jquery 函数 .slideToggle():
http://api.jquery.com/slideToggle/
这将允许您为元素设置动画,而不必检查它们当前的可见状态。
编辑
可以将选择器分配为变量并在函数之间传递它。
Check out the jquery function .slideToggle():
http://api.jquery.com/slideToggle/
This will allow you to animate your elements without necessarily having to check their current state of visibility.
EDIT
It's possible to assign a selector as a variable and pass it between functions.