setInterval
returns an ID which you then use to clear the interval.
var intervalId; on.onclick = function() { if (intervalId) { clearInterval(intervalId); } intervalId = setInterval(fontChange, 500); }; off.onclick = function() { clearInterval(intervalId); };
Related Posts:
- What’s the difference between using “let” and “var”?
- Define a global variable in a JavaScript function
- Uncaught TypeError: Cannot read property ‘length’ of undefined
- Why Is `Export Default Const` invalid?
- Angular 2 – Using ‘this’ inside setTimeout
- Javascript setInterval not working
- How do I pass the this context to a function?
- setInterval with loop time
- How to make `setInterval` behave more in sync, or how to use `setTimeout` instead?
- How to handle Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause()
- How do I make the first letter of a string uppercase in JavaScript?
- How to format a JavaScript date
- “SyntaxError: Unexpected token < in JSON at position 0"
- How can a Discord bot create a hyperlink in a Discord message in an embed or in general? [closed]
- SyntaxError: Unexpected token o in JSON at position 1
- Uncaught ReferenceError: jQuery is not defined [duplicate]
- Disabling and enabling a html input button
- How do I test for an empty JavaScript object?
- TypeScript React.FC
confusion - Check if checkbox is checked with jQuery
- Infinite Scrolling in Asp.Net MVC with jQuery / AJAX Issues
- What are the difference between $(document).bind(‘ready’, function) and $(document).ready(function() {})
- Getting “TypeError: failed to fetch” when the request hasn’t actually failed
- How can I print using JQuery
- Short circuit Array.forEach like calling break
- TypeError: Router.use() requires middleware function but got a Object
- What is the most efficient way to deep clone an object in JavaScript?
- MissingSchemaError: Schema hasn’t been registered for model “User”
- classical inheritance vs prototypal inheritance in javascript
- Uncaught TypeError: Cannot read property ‘value’ of null
- How to subtract date/time in JavaScript?
- Full-screen iframe with a height of 100%
- Async/await in componentDidMount to load in correct order
- Dynamically load JS inside JS
- Tainted canvases may not be exported
- Error: Cannot find module html
- Is it possible to append to innerHTML without destroying descendants’ event listeners?
- How to sort an object array by date property?
- React router not showing browser history
- How to define DO NOTHING in JavaScript
- How to get the difference between two arrays in JavaScript?
- What happened to Lodash _.pluck?
- Simplest/cleanest way to implement a singleton in JavaScript
- Extract hostname name from string
- How to connect signalR from angularJs
- What counts as CPU Intensive tasks (eg. sorting, searching etc?)
- HTML make text clickable without making it a hyperlink
- Uncaught ReferenceError: React is not defined
- How to get the browser viewport dimensions?
- Getting HTML form values
- How to run a function when the page is loaded?
- RegEx: How can I match all numbers greater than 49?
- Multiple left-hand assignment with JavaScript
- Disabled href tag
- How to get child element by class name?
- How to fix javascript .toFixed is not a Function error
- jQuery checkbox checked state changed event
- Javascript, viewing [object HTMLInputElement]
- JavaScript isset() equivalent
- $http.get(…).success is not a function
- How can I convert an image into Base64 string using JavaScript?
- Is there a way to create interfaces in ES6 / Node 4?
- WordPress 5.5 – ReferenceError: commonL10n is not defined error
- How to load translation in JavaScript?
- wp_register_script multiple identifiers?
- require.js to load javascript
- Setting HTML properties in a Gutenberg plugin using WordPress settings
- customize_preview_init: listening for any changes from Customizer preview area
- Enqueue scripts all over but not in single.php
- Add toggle button for mobile sub-menus
- why code javascript ,not repeat the loop main wordpress
- Adding code to head to all pages manually
- Javascript on Registration Page
- How to modify the paths of js from twentytwelve theme?
- customize-controls.js – extend api.previewer
- Unable to remove meta box from custom post for all non admin users
- how can i send this to wp_head – escape problem
- Append html to div
- Change each text after 4 second and each image after 2 second
- Hook a script as the very last one before the closing body tag
- Problem extending a core block
- google pie chart in wordpress
- How to locate the js code and php code for certain function?
- Insert HTML markup to page content from the Media Frame modal
- Add JavaScript-Library “Fitty” to WordPress
- create to search column
- Variations Javascript not working when product display on Quick view via ajax
- How do I find stylesheet & javascript handles? [duplicate]
- Mobile menu will only toggle on
- How can I stop loading wordpress jquery on header?
- Broken links help with site
- Change color of a specific word generated by script [closed]
- Passing object to FormTokenField suggestions
- How To Include JS Script with WP 2023 Theme
- Update js file on wordpress page after making changes
- How to Update a variable even if the web page reloads in js
- How do i get an Inline style in Gutenberg Block show up in front end?
- javscript that updates div in a single wordpress page
- Gutenberg core/file add style support in js/ json
- uploading image to wordpress site with javascript fetch function failed