Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
Smooth Scrolling with only vanilla JavaScript

I have always used this jQuery script for smooth scrolling:

var root = $('html, body');
$('a[href^="#"]').click(function() {
root.animate({
    scrollTop: $($.attr(this, 'href')).offset().top
}, 1000);
return false;
});

How can I do this with vanilla JavaScript? I have tried this:

document.querySelector(this.getAttribute('href')).scrollIntoView({
    behavior: 'smooth'
});

But it doesn't work with Safari, which is a deal breaker for me.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As you can read on the docs safari doesn't support options parameters on scrollIntoView so you'll need to find another method. I suggest taking a look at this alternative.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!