PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

javascript on window scroll

window.addEventListener('scroll', function() {
    console.log('scrolling');
});

// Alternative version
window.onscroll = function() {
    console.log('scrolling');
};

What's the equivalent of the following in plain JS?

$(window).scroll(function() { }); I'm also looking to animate scroll, e.g.:

$('html, body').animate({scrollTop:1750}, 'slow'); Should I be using

BETA Snippet explanation automatically generated by OpenAI:

Here is what the above code is doing:
1. On scrolling, the onscroll event is fired.
2. The function is defined.
3. The function is called.
4. The function is anonymous.
5. The function is assigned to the window.onscroll property.
6. The

Snippet By Tony Lea

ยท

Created October 19th, 2021

ยท

Report Snippet