Jump to content

Narendra Verma

Smooth scroll for specific anchor tags not for all anchor tags

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts



I am trying to implement the smooth scroll when user click on the anchor tag then it will scroll and reach the target. it's working perfectly with all the anchor tag.


Now my issue is,

I have two tabs called as part1 and part2. There is no data in part1 but I have 3-4 anchor tags in the part2. I have to set a smooth scroll for that.                                           

I don't want a smooth scroll when the user clicks on part1 or part2.  


<div class="tabs">
            <ul class="tab_click">
                  <li class="current"><a href="#part1" >Part1</a></li>
                  <li><a href="#part2">part2</a></li>

I need a smoth scroll when user click on the below anchor tag. 

          <li><a href="#about">About</a></li>
          <li><a href="#services">Services</a></li>
          <li><a href="#contact">Contact</a></li>
          <li><a href="terms.php">Terms</a></li>


Would you help me out in this issue?






See the Pen bjgXyK by Narendra_verma (@Narendra_verma) on CodePen

Link to comment
Share on other sites

I would think you could give the anonymous <ul> a class or ID and only target the <a> elements in that list rather than all of the anchors on the page.

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.