Timeout Interval Idle

码农软件 · 软件分类 · 其他jQuery插件 · 2020-01-12 19:12:06

软件介绍

Creating Timeouts and Intervals

Javascript allows you to create Timeouts and Intervals using this syntax:

setTimeout("alert('I waited 5 seconds!');",5000);
setInterval("alert('I happen every 8 seconds');",8000);

These functions are very useful, but unfortunately they only accept code as a string. This module allows you to use jQuery to create timeouts and intervals that also accept functions, like this:

$.timeout(function() { alert('I waited 5 seconds'); }, 5000);
$.interval(function() { alert('I happen every 8 seconds'); }, 8000);

You can also create Timeouts and Intervals from predefined functions:

function now() { alert('now!'); }
$.timeout(now, 5000);
$.interval(now, 8000);

Clearing Timeouts and Intervals

Javascript allows you to create and clear Timeouts and the Intervals using the following sytax:

var to = setTimeout("alert('I waited 5 seconds!');",5000);
var it = setInterval("alert('I happen every 8 seconds');",8000);
clearTimeout(to);
clearInterval(it);

Using this plugin, the same can be done like this:

var to = $.timeout(function() { alert('I waited 5 seconds'); }, 5000);
var it = $.interval(function() { alert('I happen every 8 seconds'); }, 8000);
$.clear(to);
$.clear(it);

Creating Idle Timeouts

In addition to the above functionality, this plugin provides a new type of timed function, the Idle Timeout. Every time you create a new Idle Timeout, any previous Idle Timeout is cleared. This means that you can make an event happen X seconds after the *last* time this functions is called. For example:

<input type="text" id="body" onkeypress="$.idle(function() { alert($('#body').val()); }, 3000);" />

The above code will set an Idle Timeout (and clear the last one) every time the user types into the input box. 3 seconds after the last key is pressed, the idle function will run and the contents of the input box will be alerted.

本文地址:https://codercto.com/soft/d/23241.html

人工智能

人工智能

腾讯研究院、中国信通院互联网法律研究中心、腾讯AI Lab、腾讯开放平台 / 中国人民大学出版社 / 2017-10-25 / 68.00元

面对科技的迅猛发展,中国政府制定了《新一代人工智能发展规划》,将人工智能上升到国家战略层面,并提出:不仅人工智能产业要成为新的经济增长点,而且要在2030年达到世界领先水平,让中国成为世界主要人工智能创新中心,为跻身创新型国家前列和经济强国奠定基础。 《人工智能》一书由腾讯一流团队与工信部高端智库倾力创作。本书从人工智能这一颠覆性技术的前世今生说起,对人工智能产业全貌、最新进展、发展趋势进行......一起来看看 《人工智能》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换