Is there a way to end the entire setInterval running on the javascript screen at once?

Asked 2 years ago, Updated 2 years ago, 44 views

JavaScript is using the timer using setInterval. Due to the nature of the screen, I'm using several. After Ajax communication, can all setInterval currently operating on the screen have a clearInterval effect? I want to stop the motion at once.

javascript html jquery css

2022-09-22 12:25

1 Answers

var highestIntervalId = setInterval(";");
for (var i = 0 ; i < highestIntervalId ; i++) {
  clearInterval(i);
}

setTimeout or setInterval returns an ID of the numeric type after execution, which increases with each function call.

Using the fact that the ID is an increasing number, it's a code that all clears by increasing from zero by the most recent call return.


2022-09-22 12:25

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.