jQuery Limited interval
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
   var count = 0;
   // interval
   function myInterval(){
      // toggle the text  
      $('.zzkBlink').toggle ();
      $("#countDisplay").html(count); count++;
      // stops the interval if condition true
      if(count == 10 ) {    
         //clears the interval
         clearInterval(interval);
      }
   }interval = (myInterval);
   // starts the interval
   $("#start").click(function(){
     // resets the interval
     clearInterval(interval);
     // resets the counts
     count = 0 ;
     // sets the interval
     interval = setInterval(myInterval,200);
   });
});
</script>
</head>
<body>
<button id="start">start</button>
<h1 id="countDisplay"> 0</h1>
<h1 class="zzkBlink">Blinking Text</h1>
</body>
</html>
  
 
 
23 Related pages
- About jQuery
 - AJAX Introduction
 - Copy CSS style from an element and pass it to other element, jQuery
 - Dark Light Mode website, jQuery
 - if the window size is bigger than 1000px do stuff. jQuery
 - Include CDN jQuery
 - jQuery Checkbox if else
 - jQuery input radio button
 - jQuery library included locally
 - jQuery Limited interval
 - jQuery localStorage explained
 - jQuery Next and Prev element addclasses
 - jQuery Radio button enable input
 - jQuery Refresh the page to change the background-colour
 - jQuery Screen size of this device in px
 - jQuery setInterval, On page load
 - jQuery Start / Stop interval
 - jQuery Start interval with start button
 - jquery Tick box to enable a button
 - jQury plugin form validation
 - Jump to Section in page, Distance to the top page, Smooth scroll
 - setTimeout, jQuery
 - Table Search with jQuery Misc
 























