JavaScript clearTimeout() Method

JavaScript clearTimeout() Method

The clearTimeout() method clears a timer set with the setTimeout() method.

Note: To use this method, you have to hold the setTimeout() method in a variable.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">End setTimeout</button> <p id="point"></p> <script> var myTimeout = setTimeout(myMessage, 3000); function myFunction(){ clearTimeout(myTimeout); document.getElementById("point").innerHTML = "setTimeout Ended"; } function myMessage(){ alert("I'm 3 seconds delay"); } </script> </body> </html>

Syntax

clearTimeout(var)

Parameter Values

ValueTypeExplanation
varRequiredSpecifies the name of the variable whose value is set to 'setTimeout'.

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Meet the Author