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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:35:03+00:00 2026-06-04T13:35:03+00:00

I have the following code that checks for click events on links inside of

  • 0

I have the following code that checks for click events on links inside of the
element with id = menu:

$("#menu")
   .on('click', 'a[href^="/City"]', function (event) {
   event.preventDefault();
   $('#editLink').attr("data-href", link);
});

The HTML that this code works on looks like this:

<ul id="menu">
   <li><a href="/City/0101004H">1</a></li>
   <li><a href="/City/0101004I">2</a></li>
   <li><a href="/City/0101004J">3</a></li>
   <li><a href="/City/0101004K">4</a></li>
</ul>

I have two links on another part of my screen as below:

<a id="prev" href="#">Prev</a>
<a id="next" href="#">Next</a>

How can I make it so that if a user clicks on the “2” link then these links are changed to:

<a id="prev"  href="/City/0101004H" title="City 1">Prev</a>
<a id="next"  href="/City/0101004J" title="City 3">Next</a>
  • 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-04T13:35:04+00:00Added an answer on June 4, 2026 at 1:35 pm

    You can use do like :

    $("#menu").on('click', 'a[href^="/City"]', function (event) {
       event.preventDefault();
       if(jQuery(this).text() == 2) { // this check is not required if this functionality is required for any 'a' under #menu
          jQuery(this).closest('ul').find('li:first').find('a').css('color','yellow');
          jQuery(this).closest('ul').find('li:last').find('a').css('color','pink');
          $('#prev').prop('href', $(this).parent().prev().find('a').prop('href')).prop('title','City 1').css('color','red');
          $('#next').prop('href', $(this).parent().next().find('a').prop('href')).prop('title','City 3').css('color','green');
       }
    });
    

    Fiddle

    Update:

    jQuery(this).parent().prev().find('a') // this will give prev a 
    
    jQuery(this).parent().prev().find('a') // this will give next a
    

    2nd Fiddle

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

Sidebar

Related Questions

I have the following code: $('#DoButton').click(function (event) { event.preventDefault(); $(input:checked).each(function () { var id
I have the following code on my page: $('#Report').click(Report); function Report() { var e
I have the following jQuery script... $(function() { $('.eventWrapper').bind('click', function(event) { var srvName =
I have following code that does not work due to a being a value
I have following code that does not work: I never get to goToFoodDetail .
I have following code snippet that i use to compile class at the run
I have the following code that creates a serverside object of the xmlhttp class.
I have the following code that loads a user's Active Directory DirectoryEntry object from
I have the following code that controls the presentation of an interdependent group. The
I have the following code that I am trying to extract the systems proxy

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.