Set timeout 使用 Jquery延迟执行 求助

walunwine5 2012-10-22 10:05:51
<script type=text/javascript>
jQuery(function(){
jQuery('#webmenu li').hover(function(){
jQuery(this).children('ul').stop(true,true).show('normal');
},function(){
jQuery(this).children('ul').stop(true,true).hide('slow');
});
});
</script>

这是一段弹出菜单的代码,百度了一下说是用SET TIMEOUT的方法做延迟.可是搞了半天也没搞出来.麻烦各位帮忙改一下.谢谢了只是希望鼠标放上去的时候不是马上执行.而是延迟一下再执行.
...全文
1550 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
walunwine5 2012-10-23
  • 打赏
  • 举报
回复
哈哈. 我也想好好搞着. 就是搜了白天.自己又搞了好一会还是搞不出来效果就来看看大家是怎么解决的..
泡泡鱼_ 2012-10-22
  • 打赏
  • 举报
回复
jQuery(function(){
jQuery('#webmenu li').hover(
function(){
//鼠放悬浮其上时,延迟一秒显示
var _that=jQuery(this);
setTimeout(function(){
_that.children('ul').stop(true,true).show('normal');
},1000);
},function(){
//鼠放离开后,延迟一秒隐藏
var _that=jQuery(this);
setTimeout(function(){
_that.children('ul').stop(true,true).hide('slow');
},1000);
}
);
});


PS:这个跟jQuery木有啥米关系的。基础问题,Lz你其实稍用点心,上网查查setTimeout的用法,你自己自然就会用。想学就不用这么懒的
walunwine5 2012-10-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

HTML code

function myOperation(){
alert(1111);
//jQuery(this).children('ul').stop(true,true).show('normal');
}

jQuery(function(){
jQuery('#mydiv').hover(function(){
t = setTimeout("myOperation()",……
[/Quote]


如果是加在
<script type=text/javascript>
jQuery(function(){
jQuery('#webmenu li').hover(function(){
jQuery(this).children('ul').stop(true,true).show('normal');
},function(){
jQuery(this).children('ul').stop(true,true).hide('slow');
});
});
</script>
这个原来的代码里应该是改为什么呢?我对JQuery不是很了解。谢谢你了。
franzhong 2012-10-22
  • 打赏
  • 举报
回复

function myOperation(){
alert(1111);
//jQuery(this).children('ul').stop(true,true).show('normal');
}

jQuery(function(){
jQuery('#mydiv').hover(function(){
t = setTimeout("myOperation()",1000);
})
});

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧