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 7954335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:23:57+00:00 2026-06-04T03:23:57+00:00

Example: <ul id=nav1> <li><a href=page1.html>Page 1</a></li> <li class=active><a href=page2.html>Page 2</a></li> <li><a href=page3.html>Page 3</a></li> <li><a

  • 0

Example:

<ul id="nav1">
    <li><a href="page1.html">Page 1</a></li>
    <li class="active"><a href="page2.html">Page 2</a></li>
    <li><a href="page3.html">Page 3</a></li>
    <li><a href="page4.html">Page 4</a></li>
</ul>

In this example im currently on Page 2, on Page 2 I want to place a Next Page button with an url to Page 3.

How do I get the href of Page 3 (with JavaScript)?

  • 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-06-04T03:23:59+00:00Added an answer on June 4, 2026 at 3:23 am

    If you can use jQuery

    $('.active').next('li').find('a').attr('href');  // page3.html
    

    otherwise in plain javascript (example fiddle: http://jsfiddle.net/gGRcX/2/ )

    var ul   = document.getElementsById('nav1'),
        link = ul.querySelector('li.active + li a');
    
    if (link) {   /* in case there's no "active" class 
                   * (or if it's applied on last li element) 
                   */
        console.log(link.href) // page3.html
    }
    

    querySelectorAll works on every modern browser and on IE8+

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Example Page: http://kian02.comlu.com/kian3.html I want the Navi in the example page to have mouseover
Example html: <div class=red></div> <div class=green></div> <div class=blue></div> <div class=apple></div> I want to loop
Example: template<class T> class Base { public: Base(); friend class T; }; Now this
Example: This is just\na simple sentence . I want to match every character between
I want animate this: $(#movethis).position({ my: center top, at: center bottom, of: #nav1 });
Example code: <html> <head> <script src=jquery-1.3.2.min.js type=text/javascript></script> <script src=jquery-ui-1.7.1.custom.min.js type=text/javascript></script> </head> <body> <table border=1
Example: I have an class that inherits from UIImageView. An object creates an instance
Example: I have a selector like this, which I give to another method as
Example I have a repository class (DAL): public class MyRepository : IMyRepository { public
Example: public bool Save(MyObj instance) { if (instance.IsNew) { this.repository.Create(instance); } else { this.repository.Update(instance);

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.