Programmatically trigger event on HTML element using JavaScript
Learn how to trigger an event on an HTML element using JavaScript.
The JavaScript snippet collection contains a wide variety of ES6 helper functions. Browser snippets include helper functions for selecting, traversing, and manipulating DOM elements, while general-purpose helpers can be found in the JavaScript snippet collection.
Learn how to trigger an event on an HTML element using JavaScript.
A simple trick to remove one or more attributes from an HTML element.
If you need to check if Caps Lock is on when the user is typing in the browser, JavaScript's got you covered.
Use some clever JavaScript tricks to listen for and handle scroll stop events in the browser.
Learn how to write a JSON object to a file, both using Node.js and in the browser.
Learn how to retrieve and manipulate the styles of an HTML element easily and efficiently with JavaScript.
Learn how to add an event listener that is executed at most once.
Learn how to create HTML elements in JavaScript, by abstracting the creation logic into a function.
Detect and handle click events outside of a specific element in just a few lines of JavaScript.
A quick reference for the window.location
object.
Find the distance from a given element to the top of the document with this simple JavaScript function.
Learn how to detect whether a page is being viewed on a mobile device or a desktop.
Did you know that the delay of setTimeout()
and setInterval()
is merely a suggestion?
Did you know you can use JavaScript to toggle fullscreen mode for an element on a webpage? Let's learn how!
Need to reload the current page using JavaScript? Here's the best way to do it, as well as some alternatives.
Injecting CSS into a page via JavaScript is pretty easy, if you know how to leverage the DOM.
Learn how to redirect the page to HTTPS if it's currently in HTTP.
Ever wanted to run a function on each animation frame? This snippet shows you how to do it using Window.requestAnimationFrame()
.
Determine if the current JavaScript environment is Node.js or a browser.
Want to know if a string is an absolute URL? This snippet will help you out.
JavaScript provides two methods for encoding characters to URL-safe strings. Do you know when to use each one?
Scroll listeners can easily become a performance bottleneck for your web application. Here's how to fix that.
Using Document.elementFromPoint()
to easily get the element at a specific point on the page.
Learn the difference between cookies, local storage and session storage and start using the correct option for your needs.