Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scarstens/5595132 to your computer and use it in GitHub Desktop.
Save scarstens/5595132 to your computer and use it in GitHub Desktop.
Use jquery to trigger an event every XX amount of seconds. In this example we will trigger the click event on the "increment" ID.
/* WE ARE ASSUMING JQUERY IS LOADED AND USING jQuery instead of $ */
jQuery(document).ready(function($) {
window.setInterval(function(){
/// call your function here
$('#increment').trigger('click');
}, 5000);
});
/*
* it may be better to use custom event attachment to properly sync 2 items though
* we are now assuming there are 2 buttons, a next and a previous button
*/
jQuery(document).ready(function($) {
$('#next, #prev').on('click', function() {
$('#increment').trigger('click');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment