AnsweredAssumed Answered

No longer able to hide the Next button?

Question asked by Natalee Desotell on Jul 3, 2019
Latest reply on Jul 3, 2019 by Layne Heiny

Hi everyone,


Last summer, I was able to successfully implement code which hid the 'Next' button until a certain event happened (eg, after a student clicked x times, the 'Next' button would reappear).


The code looked for the 'Next' button several times and, if it was there, it would remove it. After the student completed the task, a new function would be called to show the 'Next' button again.


Here's a snippet of the code to hide the button:


var btn = document.createElement("BUTTON");
var $nextButton = {};
$nextButton = $('.module-sequence-footer-button--next');
var checksMax = 100;
var checkCurr = 0;

function hideNext(checkCurr) {
   console.log('Checked for the next button ' + checkCurr + ' times.');
   $nextButton = $('.module-sequence-footer-button--next');

   if ($nextButton.length < 1 && checkCurr < checksMax) {
      setTimeout(function () {
      hideNext(checkCurr + 1);
}, 100);

console.log("hideNext was called")

Now, the 'Next' button is no longer being hidden even though hideNext is consistently called. The console states "Checked for the next button undefined times", so checkCurr is undefined for some reason.


I'm not sure what's going wrong this time around. Help would be appreciated if anyone knows how I can get the 'Next' button successfully hidden again. Thanks for reading!