ZaZaKi, a web developer Between Manchester UK & Rotterdam NL. © 2015-2024.

jQuery Start interval with start button

<!DOCTYPE html>
<html>
<head>

<style>.textzzk2{color:red;}</style>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){

  function myInterval(){
      $('.textzzk').toggleClass("textzzk2");
    }interval =  (myInterval);
    
    $("#start").click(function(){
      interval = setInterval(myInterval,500);
      myInterval = false; // prevents overload commands
  });
});
</script>

</head>
<body>

<button id="start">start</button>

<h1 class="textzzk">Click start button to start the interval!</h1>

</body>
</html>
Categroy:
Front-end , JQuery