Created
May 16, 2013 21:10
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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