Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3799264
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:42:19+00:00 2026-05-19T13:42:19+00:00

I have a page with several sections, and each section begins with a H2

  • 0

I have a page with several sections, and each section begins with a H2 tag. Each section has a different length from each other. I’d like to have two access keys: P and N, for “previous” and “next”.

Let’s say a user is viewing this page and scrolls to the middle of the page, and is viewing Section 5. If they hit the P access key to go to the previous section, then the browser should jump them to the H2 heading of Section 4. If they hit N to go to the next section, then they should jump to the H2 heading of Section 6.

Is it possible to do this, without needing to create a separate access key for every section? (E.g. “1” for Section 1, “2” for Section 2, etc.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T13:42:19+00:00Added an answer on May 19, 2026 at 1:42 pm

    No you don’t have to make separate keys – you only need a pointer to where the user got to and an array of all your sections… Assuming each section starts with H2 here is the code that will do what you want:

     <script>
    
      var sections = new Array();
    
    
    
      $(document).ready(function(){
      //get an array of all your sections
      sections = $("h2");
      //your pointer to a current section
      index= 0;
     $(document).keydown(function(event) {
     //previous 'p'
      if (event.keyCode == '80') {
    
      if (index!=0) {
      index--;
      } else {
      //wrap navigation (go tot the last item if on first item)
      index = sections.length-1;
      }
    
       jump(sections[index]);
         event.preventDefault();
    
       }
       //next 'n'
         if (event.keyCode == '78') {
    if (index<sections.length-1) {
         index++;
         } else {
         //wrap navigation (go the the first item if on last item)
         index = 0;
         }
    
         jump(sections[index]);
         event.preventDefault();
       }
       })
    })
    
    function jump(obj){
       var new_position = $(obj).offset();
        window.scrollTo(new_position.left,new_position.top);
    
    }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that has 5 sections. Each section takes about 1 second
I have a page that has several ajax submission forms. Each form has a
I have a complex page that has several user controls like galleries, maps, ads
I have several ReorderLists on a page. Each list has items added to it
I have a page which has several independent sections. Data is to be populated
I am building a webapp that has several main sections. Each section has several
I have a page which has several <canvas> elements. I am passing the canvas
I have a page that contains several forms, by submitting each one of them,
I have a page which requests information from several apis, some of them with
I have several links that look like the following: <ul> <li><asp:HyperLink ID=lnk1 NavigateUrl=~/section/sub-section/page1 runat=server>My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.