如果该功能尚未运行,如何执行功能? [英] How to execute a function only if that function isn't already running?

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

问题描述

我有一个每次用户更改时运行的函数。但有时用户将不得不改变多个东西,我不想再调用该函数2次或更多次。

如果它还没有运行,我怎么能让它执行?

I have a function that runs every time the user changes something. But sometimes the user will have to change multiple things and I don''t want to call the function 2 or more times..
How can I make it execute only if it isn''t already running?

推荐答案

你是如何定义onchange事件的?
how did you define the onchange event?


这是一个复选框,每当它被改变时函数执行。
It''s a checkbox and whenever it''s changed the function executes.
展开 | 选择 | Wrap | 行号


实际触发?好吧,你无法避免每个复选框在点击时触发。唯一的出路将是最终的现在计算结果。按钮。 (在(联合国)检查两个复选框之间的时间太长,第一个事件很快就会知道会有另一个事件)


您可以尝试在表单上定义模糊事件,但这不可靠,尤其是如果你不使用鼠标(例如,当选项卡选项时)
that actually fires? well, you can’t avoid that each checkbox fires when it is clicked. the only way out would be a final "calculate result now" button. (between (un)checking two checkboxes is too much time for the first event to know that there will be another event soon)

you could try to define a blur event on the form, but that is not reliable, esp. if you don’t use a mouse (e.g. when tabbing through the options)


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

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