Window clearTimeout() పద్ధతి

నిర్వచనం మరియు ఉపయోగం

clearTimeout() మార్గం స్టాప్ చేయడానికి ఉపయోగించండి setTimeout() పద్ధతి సెట్ చేసిన టైమ్ ఆఫ్ స్టాప్.

సలహా

మీరు టైమ్ ఆఫ్ స్టాప్ చేయడానికి ఉపయోగించండి setTimeout() పద్ధతి అయితే టైమ్ ఆఫ్ స్టాప్ చేయడానికి ఉపయోగించండి

myTimeout = setTimeout(function, milliseconds);

అప్పుడు మీరు కాల్ చేయడం ద్వారా clearTimeout() అమలులోకి వచ్చేటప్పుడు ఆపడానికి వచ్చును:

clearTimeout(myTimeout);

మరియు చూడండి:

setTimeout() పద్ధతి

setInterval() పద్ధతి

clearInterval() పద్ధతి

ఇన్స్టాన్స్

ఉదాహరణ 1

myGreeting() అమలులోకి వచ్చేటప్పుడు ఎలా నివారించాలి:

const myTimeout = setTimeout(myGreeting, 3000);
function myGreeting() {
  document.getElementById("demo").innerHTML = "హ్యాపీ బర్త్హ్డే టు యూ !!"
}
function myStopFunction() {
  clearTimeout(myTimeout);
}

నేను ప్రయత్నించాను

ఉదాహరణ 2

ఈ ఉదాహరణలో "స్టార్ట్" బటన్ టైమర్ ను ప్రారంభించడానికి ఉపయోగిస్తారు, కౌంటర్ కొలిగించడానికి ఉపయోగిస్తారు మరియు "స్టాప్" బటన్ టైమర్ ను ఆపడానికి ఉపయోగిస్తారు:

<button onclick="startCount()">స్టార్ట్ కౌంట్!</button>
<input type="text" id="demo">
<button onclick="stopCount()">స్టాప్ కౌంట్!</button>
<script>
let counter = 0;
let timeout;
let timer_on = 0;
function timedCount() {
  document.getElementById("demo").value = counter;
  counter++;
  timeout = setTimeout(timedCount, 1000);
}
function startCount() {
  if (!timer_on) {
    timer_on = 1;
    timedCount();
  }
}
function stopCount() {
  clearTimeout(timeout);
  timer_on = 0;
}
</script>

నేను ప్రయత్నించాను

సింథాక్స్

clearTimeout(timeoutId)

పారామితులు

పారామితులు వివరణ
timeoutId అవసరము.setTimeout() పద్ధతి తిరిగి వచ్చిన ఐడి.

వాటి వాల్యూ

కానీ లేదు.

వివరణ

clearTimeout() ప్రత్యేక కోడ్ని అడ్డుకునే పద్ధతి, కాలికించడానికి ఉపయోగిస్తారు setTimeout() పద్ధతి ఈ కోడ్లను వ్యవధిలో చేయవచ్చు. పారామితులు timeoutId కాలికించడానికి ఉపయోగిస్తారు setTimeout() పద్ధతి తర్వాత యూన్సు వాల్యూ, ఇది రద్దు చేయాల్సిన పరికరము కోడ్ బ్లాక్ ను సూచిస్తుంది (పలువురు ఉండవచ్చు).

బ్రౌజర్ మద్దతు

所有浏览器都支持 clearTimeout()కోసం

చ్రోమ్ ఐఇ ఎడ్జ్ ఫైర్ఫాక్స్ సఫారీ ఒపెరా
చ్రోమ్ ఐఇ ఎడ్జ్ ఫైర్ఫాక్స్ సఫారీ ఒపెరా
మద్దతు మద్దతు మద్దతు మద్దతు మద్దతు మద్దతు