如何立即执行功能? [英] How to execute function immediately?

查看:88
本文介绍了如何立即执行功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有10个功能:

$("#one").mouseenter(function(){
$('#two,#three,#four,#five').fadeTo(700,0.2);
});
$("#one").mouseleave(function(){
$('#two,#three,#four,#five').fadeTo(700,1);
});


$("#two").mouseenter(function(){
$('#one,#three,#four,#five').fadeTo(700,0.2);
});
$("#two").mouseleave(function(){
$('#one,#three,#four,#five').fadeTo(700,1);
});

等...

如何使每个功能立即起作用?目前,他们等待功能完成,然后再开始下一个功能.如果您在功能完成之前从第一格转到第二格,则会导致混乱例如).

how do I make each function act immediately? At the moment they wait for the function to finish before starting the next one. Which causes chaos if you go from div one to div two before the function has finished (for example).

推荐答案

$("#one").stop().fadeTo()

.stop 的文档,该文档将暂停任何当前动画.

Documentation for .stop, which halts any current animation.

我可能还会建议您使用类:

I might also suggest that you use classes:

$(".thing").mouseenter(function () {
   $(".thing").not(this).stop().fadeTo(700, 0.2);
});

这篇关于如何立即执行功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆