Helpful Scripts
setTimeout
Runs code after 1.5 seconds
setTimeout(() => {
// do something
}, 1500);setInterval
Do something every 1.5 seconds
setInterval(function () {
// do something
}, 1500);
Webflow Ready
Run code only after Webflow is ready. Useful for running code after Webflow sliders, tabs, or similar components have been created.
Set cursor div to follow mouse position
When typing on a form field, set a text element to match field value
Do something on key press
Create a press and hold interaction
Copy to clipboard
HTML
jQuery
Add a 0 in front of any number that's less than 10
JavaScript matchMedia
Run JavaScript when switching between breakpoints
Scroll to element on link click
Scrolls to ".your-section" on click of ".your-link" over 1.5 seconds
Show one random item in your cms list
Add commas to number
Show a different div for each day of the week
Apply code to a list containing 7 divs. The first div should be for Sunday.
Reload page on browser back button click
Reload page when hitting back button instead of pulling up cached version
Run code on every page that hasn't been visited before
localStorage & sessionStorage
Query Parameters
Example url: https://www.your-website.com/?username=John&hobby=Sports
Control videos
AJAX
On click of ".your-link", get ".item-on-next-page" and add it to current page.
On page load, get item from certain page and bring it to current page
Insert text into field while triggering any events attached to that field
Last updated