I have the following code,
function myCustomFunction() {
setTimeout(function () {
$('#autoplay').get(0).click();
}, 2000);
}
var isAutoplay = localStorage.getItem('autoplay');
if (isAutoplay) {
myCustomFunction();
}
$('#autoplay').on('click', function () {
localStorage.setItem('autoplay', true);
myCustomFunction();
});
// CLEAR THE LOCALSTORAGE
$('#stopplay').on('click', function () {
localStorage.removeItem('autoplay');
});
I assumed by clearing "localStorage" it would register "isAutoplay" to be false and in turn stop the myCustomFunction() function, but instead "localStorage.removeItem('autoplay');" doesn't seem to be clearing it.
How else can I stop the function from working by clicking on a link to stop the autoplay?
Thank you