Use a counter which increments each time the callback gets executed, and when it reaches your desired number of executions, use clearInterval()
to kill the timer:
var counter = 0; var i = setInterval(function(){ // do your thing counter++; if(counter === 10) { clearInterval(i); } }, 200);
Related Posts:
- Javascript setInterval not working
- How to make `setInterval` behave more in sync, or how to use `setTimeout` instead?
- clearInterval() not working [duplicate]
- addEventListener vs onclick
- How do I check if an array includes a value in JavaScript?
- JavaScript document.getElementById().value logs empty value
- Understanding unique keys for array children in React.js
- (Google Map API) Geocode was not successful for the following reason: REQUEST_DENIED
- Generate random number between two numbers in JavaScript
- Difference between npx and npm?
- How do I copy to the clipboard in JavaScript?
- Array of JSON Objects
- Cannot read property ‘push’ of undefined when combining arrays
- window.onload vs document.onload
- Fetch: POST JSON data
- JavaScript hide/show element
- Copy array by value
- How to call an async arrow function with await
- Get the current URL with JavaScript?
- How do I empty an array in JavaScript?
- What’s the difference between event.stopPropagation and event.preventDefault?
- ReferenceError: fetch is not defined
- Firebase Permission Denied
- Using Javascript in CSS
- How can I mock an ES6 module import using Jest?
- What is “assert” in JavaScript?
- How does the data-toggle attribute work? (What’s its API?)
- How to import image (.svg, .png ) in a React Component
- How do I embed PHP code in JavaScript?
- Make javascript alert Yes/No Instead of Ok/Cancel
- How to create a dialog with “yes” and “no” options
- Adding images to a Bootstrap Carousel with AJAX
- SyntaxError: Cannot use import statement outside a module
- Appending to an object
- What is the meaning of “$” sign in JavaScript
- How to determine the installed webpack version
- Error: Failed to execute ‘appendChild’ on ‘Node’: parameter 1 is not of type ‘Node’
- How to validate date with format “mm/dd/yyyy” in JavaScript?
- How to handle the `onKeyPress` event in ReactJS?
- ES6: Create Strings using Template Literals – Freecodecamp
- Youtube api – stop video
- Uncaught TypeError: Cannot read property ‘msie’ of undefined – jQuery tools
- node-request – Getting error “SSL23_GET_SERVER_HELLO:unknown protocol”
- React.js – Can’t read property of undefined
- SyntaxError: import declarations may only appear at top level of a module
- Jest TypeError: Path must be a string. Received undefined
- How do I convert an integer to binary in JavaScript?
- For loop for HTMLCollection elements
- Refresh/reload the content in Div using jquery/ajax
- How to take keyboard input in JavaScript?
- Convert CSV data into JSON format using Javascript
- Can not solve: Geocode was not successful for the following reason: OVER_QUERY_LIMIT
- Return array from function
- Why define an anonymous function and pass it jQuery as the argument?
- Error parsing XHTML: The content of elements must consist of well-formed character data or markup
- How to scroll an HTML page to a given anchor
- Javascript call() & apply() vs bind()?
- “google is not defined” when using Google Maps V3 in Firefox remotely
- how to call a onclick function in tag?
- How to sort an array of integers correctly
- Failed to execute ‘postMessage’ on ‘DOMWindow’: https://www.youtube.com !== http://localhost:9000
- what is the best way to check variable type in javascript
- JavaScript Array Push key value
- stopPropagation vs. stopImmediatePropagation
- typescript – cloning object
- Ajax success function
- Register and enqueue conditional (browser-specific) javascript files?
- How to replace regular jquery calls with CDN calls from Google?
- Editing Source Code in WordPress
- How/Where is editor.min.js Added to the wp-admin Post Page?
- Why is this gutenberg custom format button only available from the toolbar as a dropdown?
- Close TinyMCE plugin window on click away
- VB.net and WordPress
- Gutenberg passing block attributes to component in ES6/ESNext
- Script Localization doesn’t work
- How to conditionally show/hide controls & sections in WordPress customizer?
- Uncaught TypeError [closed]
- Correct way to include extra styles & script files?
- How can I allow HTML in Gutenberg UI elements help text?
- How to move core js files into the footer
- Building a Featured Gallery component for Gutenberg
- Should I manually resolve WP Core File security issues or await a subsequent WP release?
- Retrieving data about comments and likes
- Including Styles and JS files to work ON my plugin interface
- Linking wp_enqueue can’t find the javascript file (adds “?ver=x.x.x” to the src)
- My code will not execute in wordpress, even though I’ve been told the code is fine
- Gutenberg – dynamically created element: how to set onChange?
- JSX SVG Icon with WordPress
- Javascript working on jsfiddle but not wordpress site?
- Drodown list return issue
- Can I just insert JavaScript by using ?
- Gutenberg Edit Block Inspector Controls and save
- JavaScript and Google PageSpeed + wp_enqueue_script
- Put dynamic Javascript in header after doing operations
- Adding javascript blocks to a single file and adding it to the header
- How to integrate a different (JavaScript) editor in WordPress?
- Add Javascript/Html into a WordPress
- WP REST API – “rest_user_cannot_view” ONLY on specific users
- Uncaught ReferenceError: tippy is not defined
- How to add a new attribute to core wp block editor without npm?