Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

setinterval on and off

//setinterval on and off

h1 = document.querySelector("h1")
h2 = 0
document.querySelector("#onoff").value = "On"

function funi(){
  tr = setInterval(() =>h1.innerHTML = h2 ++, 1000)
  }

function onoff(){
  currentvalue = document.getElementById('onoff').value;
  if(currentvalue == "Off"){
  clearInterval(tr)
  document.getElementById("onoff").value="On";
  }else{
    funi()
    document.getElementById("onoff").value="Off";
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: progress bar loading ajax 
Javascript :: how to change image on mouse click in javascript 
Javascript :: lodash groupby return array 
Javascript :: next js latest 
Javascript :: import math javascript 
Javascript :: how to fetch data redux 
Javascript :: json object array 
Javascript :: review rating design 
Javascript :: how to get child element in javascript 
Javascript :: how to parse header in node.js lambda 
Javascript :: create an express application 
Javascript :: javascript compare dates 
Javascript :: mongoose populate array of ids 
Javascript :: validatorjs number 
Javascript :: big o theory 
Javascript :: circular queue in javascript 
Javascript :: linked list algorithm javascript 
Javascript :: concate array to string javascript 
Javascript :: when to use previous state in useState 
Javascript :: js Destructuring arrays and objects 
Javascript :: jwt token npm 
Javascript :: get html 
Javascript :: reduce javascript 
Javascript :: how to stop angular server 
Javascript :: javascript greater than or equal to 
Javascript :: render html page in javascript 
Javascript :: node.js global variables 
Javascript :: Change Title In React Project 
Javascript :: quote 
Javascript :: js keycodes 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =