Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Narendra Verma

Smooth scroll for specific anchor tags not for all anchor tags

Recommended Posts

Hello,

 

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>
            </ul>
      </div>


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

<ul>
          <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>
        </ul>

 

Would you help me out in this issue?

 

 

 

 

 

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

Link to post
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 post
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.

×