This works fine:
$('.mainRotatorPaginator a').click(function() {
$(this).everyTime(1000, 'rotation', function(i) {
$('.mainRotatorPaginator').css('outline', '1px solid green'); //test
});
});
But I want a timer to start as soon as the page loads, not to wait for a user event.
I'm following the examples at http://plugins.jquery.com/project/timers, but this just isn't doing anything:
$(document).everyTime(1000, function (i) {
$('.mainRotatorPaginator').css('outline', '1px solid green'); //test
}, 10);
Any help?
SOLUTION
OK, turns out the solution is related to Samich's (and Joe's) answer: even though all my jQuery calls were already nested inside $(document).ready in a file containing all my custom jQuery code, I tried pasting the suggestion anyway, just for giggles. To my surprise, this worked, and it开发者_JS百科 turns out it's because I'd pasted the plugin inside the outer $(document).ready, but at the bottom, after the $(document).everyTime() call, so the file's code reached my call first, and the plugin's functions weren't yet defined.
So the best thing is to stick the plugin in it's own $(document).ready(function());, and place above the block where all my custom jQuery resides. (and I'll minify it first -- wondering why they don't offer a minified version?)
$(document).ready(function()
{
$(document).everyTime(1000, function (i) {
$('.mainRotatorPaginator').css('outline', '1px solid green'); //test
}, 10);
});
$(document).ready(function() {
$(document).everyTime(1000, function (i) {
$('.mainRotatorPaginator').css('outline', '1px solid green'); //test
}, 10);
});
According to this post jquery "everyTime" function you can specify interval as string value
$(document).everyTime('1s', function (i) { })
精彩评论