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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:04:53+00:00 2026-06-16T12:04:53+00:00

I have a loop of links on a website I’m working on. Each link

  • 0

I have a loop of links on a website I’m working on. Each link has a unique ID and when I click on one of these links, the link will be highlighted with bold text. If I’m clicking on another link, the highlighted link will be replaced with the one I have just clicked on.

Example code (please see the jsFiddle example):

$('body').on('click', '#link-1', function() {
    if($(this).hasClass('normal-text')) {
        $(this).removeClass('normal-text');
        $(this).addClass('bold-text');

    } else if($(this).hasClass('bold-text')) {
        $(this).removeClass('bold-text');
        $(this).addClass('normal-text');
    }
});

How can I accomplish this?

Basic demo: http://jsfiddle.net/edgren/3VXVL/

Live demo to see exactly how I mean: the problem has been solved

Thanks in advance.

  • 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-16T12:04:54+00:00Added an answer on June 16, 2026 at 12:04 pm

    Try this http://jsfiddle.net/3VXVL/4/

    javascript:

    $(document).ready(function() {
        $('body').on('click', '.link', function() {
            $('.bold-text').removeClass('bold-text');
            $(this).addClass('bold-text');
        });
    });
    

    html:

    <a href="javascript:void(0)" id="link-1" class="link normal-text">Link 1</a> - 
    <a href="javascript:void(0)" id="link-2" class="link normal-text">Link 2</a> - 
    <a href="javascript:void(0)" id="link-3" class="link normal-text">Link 3</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following rails code in a loop that has a link for
I have a for each loop on the inbox page of my website: <table
Right now I have a foreach loop that grabs the first link with an
I have loop and each iteration of Hash looks like this: [1, {:clid=>1, :nvz=>4,
In Wordpress, I have a website for an estate agents which has 3 taxonomies
I have a loop which outputs information I grabbed from a website. To make
I have a list of words, in Python I need to loop through each
I am working on a property website and have record sets for property and
I have a loop which outputs some information I grabbed from a website. To
I have a loop that finds duplicate lines in a .ini file. I can

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.