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

社群营销实战手册

社群营销实战手册

秋叶、邻三月、秦阳 / 人民邮电出版社 / 2018-1 / 69.00元

互联网正从“物以类聚”,走向“人以群分”的时代。秋叶等人的“社群营销”,并非单纯靠社群卖东西,而是建立一种中心化的、自行运转的生态,让“同好”们形成紧密的联系,创造出海量营销机会。 《社群营销实战手册 从社群运营到社群经济》共5章内容,从社群的定位、建立、扩张、变现、运营,到社群的生命周期延长、社群运营团队的打造和管理以及社群管理工具,大量干货秘笈一应俱全,并提供丰富的运营实战案例,全面解读社群的......一起来看看 《社群营销实战手册》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具