How to Stop Setinterval() After Sometimes in JQuery?

By Hardik Savani June 17, 2023 Category : jQuery

Hello Friends,

This detailed guide will cover jquery setinterval stop after sometime. This tutorial will give you a simple example of setinterval jquery stop timer example. you will learn javascript setinterval stops after a while. In this article, we will implement a javascript setinterval stop itself. So, let's follow a few steps to create an example of how to stop setinterval after some time in jquery.

Sometimes we require to stop setInterval() after a while few time, so today i am going to give you simple example with setinterval stops after a while.

In this example i used two function as listed bellow:

setInterval() : Call on specified intervals time.

clearInterval() : Stop set interval.

You can see bellow full example, how to stop setinterval after 1 minute, You can also check demo, how work this example:


<!DOCTYPE html>



<title>Jquery setinterval stop after sometime</title>

<script type="text/javascript" src="//"></script>



<button>Click to Start</button>


<script type="text/javascript">

$(document).ready(function() {



$("pre").append('Stop After 1min.<br/>');

var countTime = 0;

var storeTimeInterval = setInterval(function(){


$("pre").append(countTime*5 + 'sec.<br/>');

if(countTime == 12){




}, 5000);






Maybe it can help you...

Tags :