I have a pretty unique situation where I need a bunch of jQuery code to re-execute on a button click. The added complications are:
- I can't allow the browser window to refresh
- All the code is within a setTimeout() parameter - not sure if this really matters
I can't wrap the code inside a click event as it needs to run automatically on first opening or refresh of the page. To add a bit of context I've mocked up the following:
setTimeout(function() {
// all the scripts that need to run
}, 2500);
$('.btn').click(function() {
// re-run the above code without refreshing window or browser
});
Is there a way to re-run the code on a button click in this context?